LCOV - code coverage report
Current view: top level - sw/source/core/doc - docdraw.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 128 421 30.4 %
Date: 2012-08-25 Functions: 18 29 62.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 116 646 18.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <hintids.hxx>
      31                 :            : #include <rtl/logfile.hxx>
      32                 :            : #include <vcl/outdev.hxx>
      33                 :            : #include <sfx2/printer.hxx>
      34                 :            : #include <editeng/eeitem.hxx>
      35                 :            : #include <editeng/flditem.hxx>
      36                 :            : #include <editeng/editeng.hxx>
      37                 :            : #include <svx/svdoutl.hxx>
      38                 :            : #include <editeng/colritem.hxx>
      39                 :            : #include <svx/svdpage.hxx>
      40                 :            : #include <svx/svdogrp.hxx>
      41                 :            : #include <editeng/langitem.hxx>
      42                 :            : #include <editeng/unolingu.hxx>
      43                 :            : #include <editeng/measfld.hxx>
      44                 :            : #include <svx/svdpool.hxx>
      45                 :            : #include <fmtanchr.hxx>
      46                 :            : #include <charatr.hxx>
      47                 :            : #include <frmfmt.hxx>
      48                 :            : #include <charfmt.hxx>
      49                 :            : #include <viewimp.hxx>
      50                 :            : #include <swhints.hxx>
      51                 :            : #include <doc.hxx>
      52                 :            : #include <IDocumentUndoRedo.hxx>
      53                 :            : #include <docsh.hxx>
      54                 :            : #include <rootfrm.hxx>          // So that the RootDtor is called.
      55                 :            : #include <poolfmt.hxx>
      56                 :            : #include <viewsh.hxx>           // for MakeDrawView
      57                 :            : #include <drawdoc.hxx>
      58                 :            : #include <UndoDraw.hxx>
      59                 :            : #include <swundo.hxx>           // for the UndoIds
      60                 :            : #include <dcontact.hxx>
      61                 :            : #include <dview.hxx>
      62                 :            : #include <mvsave.hxx>
      63                 :            : #include <flyfrm.hxx>
      64                 :            : #include <dflyobj.hxx>
      65                 :            : #include <svx/svdetc.hxx>
      66                 :            : #include <editeng/fhgtitem.hxx>
      67                 :            : #include <svx/svdpagv.hxx>
      68                 :            : #include <txtfrm.hxx>
      69                 :            : #include <editeng/frmdiritem.hxx>
      70                 :            : #include <fmtornt.hxx>
      71                 :            : #include <svx/svditer.hxx>
      72                 :            : 
      73                 :            : #include <vector>
      74                 :            : #include <switerator.hxx>
      75                 :            : 
      76                 :            : using namespace ::com::sun::star;
      77                 :            : using namespace ::com::sun::star::linguistic2;
      78                 :            : 
      79                 :            : /*************************************************************************
      80                 :            : |*
      81                 :            : |*  SwDoc::GroupSelection / SwDoc::UnGroupSelection
      82                 :            : |*
      83                 :            : |*************************************************************************/
      84                 :            : // local method to determine positioning and
      85                 :            : // alignment attributes for a drawing object, which is newly connected to
      86                 :            : // the layout. Used for a newly formed group object <SwDoc::GroupSelection(..)>
      87                 :            : // and the members of a destroyed group <SwDoc::UnGroupSelection(..)>
      88                 :          0 : void lcl_AdjustPositioningAttr( SwDrawFrmFmt* _pFrmFmt,
      89                 :            :                                 const SdrObject& _rSdrObj )
      90                 :            : {
      91                 :          0 :     const SwContact* pContact = GetUserCall( &_rSdrObj );
      92                 :            :     OSL_ENSURE( pContact, "<lcl_AdjustPositioningAttr(..)> - missing contact object." );
      93                 :            : 
      94                 :            :     // determine position of new group object relative to its anchor frame position
      95                 :          0 :     SwTwips nHoriRelPos = 0;
      96                 :          0 :     SwTwips nVertRelPos = 0;
      97                 :            :     {
      98 [ #  # ][ #  # ]:          0 :         const SwFrm* pAnchorFrm = pContact->GetAnchoredObj( &_rSdrObj )->GetAnchorFrm();
      99                 :            :         OSL_ENSURE( !pAnchorFrm ||
     100                 :            :                 !pAnchorFrm->IsTxtFrm() ||
     101                 :            :                 !static_cast<const SwTxtFrm*>(pAnchorFrm)->IsFollow(),
     102                 :            :                 "<lcl_AdjustPositioningAttr(..)> - anchor frame is a follow. Please inform OD." );
     103                 :          0 :         bool bVert = false;
     104                 :          0 :         bool bR2L = false;
     105                 :            :         // #i45952# - use anchor position of anchor frame, if it exist.
     106                 :          0 :         Point aAnchorPos;
     107         [ #  # ]:          0 :         if ( pAnchorFrm )
     108                 :            :         {
     109                 :            :             // #i45952#
     110 [ #  # ][ #  # ]:          0 :             aAnchorPos = pAnchorFrm->GetFrmAnchorPos( ::HasWrap( &_rSdrObj ) );
     111         [ #  # ]:          0 :             bVert = pAnchorFrm->IsVertical();
     112         [ #  # ]:          0 :             bR2L = pAnchorFrm->IsRightToLeft();
     113                 :            :         }
     114                 :            :         else
     115                 :            :         {
     116                 :            :             // #i45952#
     117         [ #  # ]:          0 :             aAnchorPos = _rSdrObj.GetAnchorPos();
     118                 :            :             // If no anchor frame exist - e.g. because no layout exists - the
     119                 :            :             // default layout direction is taken.
     120                 :            :             const SvxFrameDirectionItem* pDirItem =
     121         [ #  # ]:          0 :                 static_cast<const SvxFrameDirectionItem*>(&(_pFrmFmt->GetAttrSet().GetPool()->GetDefaultItem( RES_FRAMEDIR )));
     122   [ #  #  #  #  :          0 :             switch ( pDirItem->GetValue() )
                      # ]
     123                 :            :             {
     124                 :            :                 case FRMDIR_VERT_TOP_LEFT:
     125                 :            :                 {
     126                 :            :                     // vertical from left-to-right - Badaa: supported now!
     127                 :          0 :                     bVert = true;
     128                 :          0 :                     bR2L = true;
     129                 :            :                     OSL_FAIL( "<lcl_AdjustPositioningAttr(..)> - vertical from left-to-right not supported." );
     130                 :            :                 }
     131                 :          0 :                 break;
     132                 :            :                 case FRMDIR_VERT_TOP_RIGHT:
     133                 :            :                 {
     134                 :            :                     // vertical from right-to-left
     135                 :          0 :                     bVert = true;
     136                 :          0 :                     bR2L = false;
     137                 :            :                 }
     138                 :          0 :                 break;
     139                 :            :                 case FRMDIR_HORI_RIGHT_TOP:
     140                 :            :                 {
     141                 :            :                     // horizontal from right-to-left
     142                 :          0 :                     bVert = false;
     143                 :          0 :                     bR2L = true;
     144                 :            :                 }
     145                 :          0 :                 break;
     146                 :            :                 case FRMDIR_HORI_LEFT_TOP:
     147                 :            :                 {
     148                 :            :                     // horizontal from left-to-right
     149                 :          0 :                     bVert = false;
     150                 :          0 :                     bR2L = false;
     151                 :            :                 }
     152                 :          0 :                 break;
     153                 :            :             }
     154                 :            : 
     155                 :            :         }
     156                 :            :         // use geometry of drawing object
     157 [ #  # ][ #  # ]:          0 :         const SwRect aObjRect = _rSdrObj.GetSnapRect();
     158                 :            : 
     159         [ #  # ]:          0 :         if ( bVert )
     160                 :            :         {
     161         [ #  # ]:          0 :             if ( bR2L ) {
     162                 :            :                   //FRMDIR_VERT_TOP_LEFT
     163                 :          0 :                   nHoriRelPos = aObjRect.Left() - aAnchorPos.X();
     164                 :          0 :                   nVertRelPos = aObjRect.Top() - aAnchorPos.Y();
     165                 :            :             } else {
     166                 :            :                 //FRMDIR_VERT_TOP_RIGHT
     167                 :          0 :                 nHoriRelPos = aObjRect.Top() - aAnchorPos.Y();
     168                 :          0 :                 nVertRelPos = aAnchorPos.X() - aObjRect.Right();
     169                 :            :             }
     170                 :            :         }
     171         [ #  # ]:          0 :         else if ( bR2L )
     172                 :            :         {
     173                 :          0 :             nHoriRelPos = aAnchorPos.X() - aObjRect.Right();
     174                 :          0 :             nVertRelPos = aObjRect.Top() - aAnchorPos.Y();
     175                 :            :         }
     176                 :            :         else
     177                 :            :         {
     178                 :          0 :             nHoriRelPos = aObjRect.Left() - aAnchorPos.X();
     179                 :          0 :             nVertRelPos = aObjRect.Top() - aAnchorPos.Y();
     180                 :            :         }
     181                 :            :         //End of SCMS
     182                 :            :     }
     183                 :            : 
     184         [ #  # ]:          0 :     _pFrmFmt->SetFmtAttr( SwFmtHoriOrient( nHoriRelPos, text::HoriOrientation::NONE, text::RelOrientation::FRAME ) );
     185         [ #  # ]:          0 :     _pFrmFmt->SetFmtAttr( SwFmtVertOrient( nVertRelPos, text::VertOrientation::NONE, text::RelOrientation::FRAME ) );
     186                 :            :     // #i44334#, #i44681# - positioning attributes already set
     187                 :          0 :     _pFrmFmt->PosAttrSet();
     188                 :            :     // #i34750# - keep current object rectangle for  drawing
     189                 :            :     // objects. The object rectangle is used on events from the drawing layer
     190                 :            :     // to adjust the positioning attributes - see <SwDrawContact::_Changed(..)>.
     191                 :            :     {
     192                 :          0 :         const SwAnchoredObject* pAnchoredObj = pContact->GetAnchoredObj( &_rSdrObj );
     193         [ #  # ]:          0 :         if ( pAnchoredObj->ISA(SwAnchoredDrawObject) )
     194                 :            :         {
     195                 :            :             const SwAnchoredDrawObject* pAnchoredDrawObj =
     196                 :          0 :                             static_cast<const SwAnchoredDrawObject*>(pAnchoredObj);
     197 [ #  # ][ #  # ]:          0 :             const SwRect aObjRect = _rSdrObj.GetSnapRect();
     198                 :            :             const_cast<SwAnchoredDrawObject*>(pAnchoredDrawObj)
     199 [ #  # ][ #  # ]:          0 :                                         ->SetLastObjRect( aObjRect.SVRect() );
     200                 :            :         }
     201                 :            :     }
     202                 :          0 : }
     203                 :            : 
     204                 :          0 : SwDrawContact* SwDoc::GroupSelection( SdrView& rDrawView )
     205                 :            : {
     206                 :            :     // replace marked 'virtual' drawing objects by the corresponding 'master'
     207                 :            :     // drawing objects.
     208                 :          0 :     SwDrawView::ReplaceMarkedDrawVirtObjs( rDrawView );
     209                 :            : 
     210                 :          0 :     const SdrMarkList &rMrkList = rDrawView.GetMarkedObjectList();
     211                 :          0 :     SwDrawFrmFmt *pFmt = 0L;
     212                 :          0 :     SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
     213                 :          0 :     sal_Bool bNoGroup = ( 0 == pObj->GetUpGroup() );
     214                 :          0 :     SwDrawContact* pNewContact = 0;
     215         [ #  # ]:          0 :     if( bNoGroup )
     216                 :            :     {
     217                 :            :         // Revoke anchor attribute.
     218         [ #  # ]:          0 :         SwDrawContact *pMyContact = (SwDrawContact*)GetUserCall(pObj);
     219 [ #  # ][ #  # ]:          0 :         const SwFmtAnchor aAnch( pMyContact->GetFmt()->GetAnchor() );
     220                 :            : 
     221 [ #  # ][ #  # ]:          0 :         SwUndoDrawGroup *const pUndo = (!GetIDocumentUndoRedo().DoesUndo())
     222                 :            :                                  ? 0
     223 [ #  # ][ #  # ]:          0 :                                  : new SwUndoDrawGroup( (sal_uInt16)rMrkList.GetMarkCount() );
                 [ #  # ]
     224                 :            : 
     225                 :            :         // #i53320#
     226                 :          0 :         bool bGroupMembersNotPositioned( false );
     227                 :            :         {
     228                 :            :             SwAnchoredDrawObject* pAnchoredDrawObj =
     229         [ #  # ]:          0 :                 static_cast<SwAnchoredDrawObject*>(pMyContact->GetAnchoredObj( pObj ));
     230                 :          0 :             bGroupMembersNotPositioned = pAnchoredDrawObj->NotYetPositioned();
     231                 :            :         }
     232                 :            :         // Destroy ContactObjects and formats.
     233         [ #  # ]:          0 :         for( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i )
     234                 :            :         {
     235 [ #  # ][ #  # ]:          0 :             pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
     236         [ #  # ]:          0 :             SwDrawContact *pContact = (SwDrawContact*)GetUserCall(pObj);
     237                 :            : 
     238                 :            :             // #i53320#
     239                 :            : #if OSL_DEBUG_LEVEL > 0
     240                 :            :             SwAnchoredDrawObject* pAnchoredDrawObj =
     241                 :            :                 static_cast<SwAnchoredDrawObject*>(pContact->GetAnchoredObj( pObj ));
     242                 :            :             OSL_ENSURE( bGroupMembersNotPositioned == pAnchoredDrawObj->NotYetPositioned(),
     243                 :            :                     "<SwDoc::GroupSelection(..)> - group members have different positioning status!" );
     244                 :            : #endif
     245                 :            : 
     246                 :          0 :             pFmt = (SwDrawFrmFmt*)pContact->GetFmt();
     247                 :            :             // Deletes itself!
     248 [ #  # ][ #  # ]:          0 :             pContact->Changed(*pObj, SDRUSERCALL_DELETE, pObj->GetLastBoundRect() );
     249         [ #  # ]:          0 :             pObj->SetUserCall( 0 );
     250                 :            : 
     251         [ #  # ]:          0 :             if( pUndo )
     252         [ #  # ]:          0 :                 pUndo->AddObj( i, pFmt, pObj );
     253                 :            :             else
     254         [ #  # ]:          0 :                 DelFrmFmt( pFmt );
     255                 :            : 
     256                 :            :             // #i45952# - re-introduce position normalization of group member
     257                 :            :             // objects, because its anchor position is cleared, when they are
     258                 :            :             // grouped.
     259         [ #  # ]:          0 :             Point aAnchorPos( pObj->GetAnchorPos() );
     260         [ #  # ]:          0 :             pObj->NbcSetAnchorPos( Point( 0, 0 ) );
     261         [ #  # ]:          0 :             pObj->NbcMove( Size( aAnchorPos.X(), aAnchorPos.Y() ) );
     262                 :            :         }
     263                 :            : 
     264                 :            :         pFmt = MakeDrawFrmFmt( rtl::OUString("DrawObject"),
     265 [ #  # ][ #  # ]:          0 :                                 GetDfltFrmFmt() );
                 [ #  # ]
     266         [ #  # ]:          0 :         pFmt->SetFmtAttr( aAnch );
     267                 :            :         // #i36010# - set layout direction of the position
     268                 :            :         pFmt->SetPositionLayoutDir(
     269         [ #  # ]:          0 :             text::PositionLayoutDir::PositionInLayoutDirOfAnchor );
     270                 :            : 
     271         [ #  # ]:          0 :         rDrawView.GroupMarked();
     272                 :            :         OSL_ENSURE( rMrkList.GetMarkCount() == 1, "GroupMarked more or none groups." );
     273                 :            : 
     274 [ #  # ][ #  # ]:          0 :         SdrObject* pNewGroupObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
     275 [ #  # ][ #  # ]:          0 :         pNewContact = new SwDrawContact( pFmt, pNewGroupObj );
     276                 :            :         // #i35635#
     277         [ #  # ]:          0 :         pNewContact->MoveObjToVisibleLayer( pNewGroupObj );
     278         [ #  # ]:          0 :         pNewContact->ConnectToLayout();
     279                 :            :         // #i53320# - No adjustment of the positioning and alignment
     280                 :            :         // attributes, if group members aren't positioned yet.
     281         [ #  # ]:          0 :         if ( !bGroupMembersNotPositioned )
     282                 :            :         {
     283                 :            :             // #i26791# - Adjust positioning and alignment attributes.
     284         [ #  # ]:          0 :             lcl_AdjustPositioningAttr( pFmt, *pNewGroupObj );
     285                 :            :         }
     286                 :            : 
     287         [ #  # ]:          0 :         if( pUndo )
     288                 :            :         {
     289         [ #  # ]:          0 :             pUndo->SetGroupFmt( pFmt );
     290 [ #  # ][ #  # ]:          0 :             GetIDocumentUndoRedo().AppendUndo( pUndo );
     291         [ #  # ]:          0 :         }
     292                 :            :     }
     293                 :            :     else
     294                 :            :     {
     295         [ #  # ]:          0 :         if (GetIDocumentUndoRedo().DoesUndo())
     296                 :            :         {
     297                 :          0 :             GetIDocumentUndoRedo().ClearRedo();
     298                 :            :         }
     299                 :            : 
     300                 :          0 :         rDrawView.GroupMarked();
     301                 :            :         OSL_ENSURE( rMrkList.GetMarkCount() == 1, "GroupMarked more or none groups." );
     302                 :            :     }
     303                 :            : 
     304                 :          0 :     return pNewContact;
     305                 :            : }
     306                 :            : 
     307                 :            : 
     308                 :          0 : void SwDoc::UnGroupSelection( SdrView& rDrawView )
     309                 :            : {
     310                 :          0 :     bool const bUndo = GetIDocumentUndoRedo().DoesUndo();
     311         [ #  # ]:          0 :     if( bUndo )
     312                 :            :     {
     313                 :          0 :         GetIDocumentUndoRedo().ClearRedo();
     314                 :            :     }
     315                 :            : 
     316                 :            :     // replace marked 'virtual' drawing objects by the corresponding 'master'
     317                 :            :     // drawing objects.
     318                 :          0 :     SwDrawView::ReplaceMarkedDrawVirtObjs( rDrawView );
     319                 :            : 
     320                 :          0 :     const SdrMarkList &rMrkList = rDrawView.GetMarkedObjectList();
     321                 :          0 :     std::vector< std::pair< SwDrawFrmFmt*, SdrObject* > >* pFmtsAndObjs( 0L );
     322                 :          0 :     const sal_uInt32 nMarkCount( rMrkList.GetMarkCount() );
     323         [ #  # ]:          0 :     if ( nMarkCount )
     324                 :            :     {
     325 [ #  # ][ #  #  :          0 :         pFmtsAndObjs = new std::vector< std::pair< SwDrawFrmFmt*, SdrObject* > >[nMarkCount];
             #  #  #  # ]
     326                 :          0 :         SdrObject *pMyObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
     327         [ #  # ]:          0 :         if( !pMyObj->GetUpGroup() )
     328                 :            :         {
     329                 :          0 :             rtl::OUString sDrwFmtNm("DrawObject");
     330         [ #  # ]:          0 :             for ( sal_uInt16 i = 0; i < nMarkCount; ++i )
     331                 :            :             {
     332 [ #  # ][ #  # ]:          0 :                 SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
     333 [ #  # ][ #  # ]:          0 :                 if ( pObj->IsA( TYPE(SdrObjGroup) ) )
                 [ #  # ]
     334                 :            :                 {
     335         [ #  # ]:          0 :                     SwDrawContact *pContact = (SwDrawContact*)GetUserCall(pObj);
     336 [ #  # ][ #  # ]:          0 :                     SwFmtAnchor aAnch( pContact->GetFmt()->GetAnchor() );
     337         [ #  # ]:          0 :                     SdrObjList *pLst = ((SdrObjGroup*)pObj)->GetSubList();
     338                 :            : 
     339                 :          0 :                     SwUndoDrawUnGroup* pUndo = 0;
     340         [ #  # ]:          0 :                     if( bUndo )
     341                 :            :                     {
     342 [ #  # ][ #  # ]:          0 :                         pUndo = new SwUndoDrawUnGroup( (SdrObjGroup*)pObj );
     343 [ #  # ][ #  # ]:          0 :                         GetIDocumentUndoRedo().AppendUndo(pUndo);
     344                 :            :                     }
     345                 :            : 
     346 [ #  # ][ #  # ]:          0 :                     for ( sal_uInt16 i2 = 0; i2 < pLst->GetObjCount(); ++i2 )
     347                 :            :                     {
     348         [ #  # ]:          0 :                         SdrObject* pSubObj = pLst->GetObj( i2 );
     349                 :            :                         SwDrawFrmFmt *pFmt = MakeDrawFrmFmt( sDrwFmtNm,
     350 [ #  # ][ #  # ]:          0 :                                                             GetDfltFrmFmt() );
                 [ #  # ]
     351         [ #  # ]:          0 :                         pFmt->SetFmtAttr( aAnch );
     352                 :            :                         // #i36010# - set layout direction of the position
     353                 :            :                         pFmt->SetPositionLayoutDir(
     354         [ #  # ]:          0 :                             text::PositionLayoutDir::PositionInLayoutDirOfAnchor );
     355 [ #  # ][ #  # ]:          0 :                         pFmtsAndObjs[i].push_back( std::pair< SwDrawFrmFmt*, SdrObject* >( pFmt, pSubObj ) );
     356                 :            : 
     357         [ #  # ]:          0 :                         if( bUndo )
     358         [ #  # ]:          0 :                             pUndo->AddObj( i2, pFmt );
     359         [ #  # ]:          0 :                     }
     360                 :            :                 }
     361                 :          0 :             }
     362                 :            :         }
     363                 :            :     }
     364                 :          0 :     rDrawView.UnGroupMarked();
     365                 :            :     // creation of <SwDrawContact> instances for the former group members and
     366                 :            :     // its connection to the Writer layout.
     367         [ #  # ]:          0 :     for ( sal_uInt32 i = 0; i < nMarkCount; ++i )
     368                 :            :     {
     369                 :          0 :         SwUndoDrawUnGroupConnectToLayout* pUndo = 0;
     370         [ #  # ]:          0 :         if( bUndo )
     371                 :            :         {
     372         [ #  # ]:          0 :             pUndo = new SwUndoDrawUnGroupConnectToLayout();
     373                 :          0 :             GetIDocumentUndoRedo().AppendUndo(pUndo);
     374                 :            :         }
     375                 :            : 
     376         [ #  # ]:          0 :         while ( pFmtsAndObjs[i].size() > 0 )
     377                 :            :         {
     378                 :          0 :             SwDrawFrmFmt* pFmt( pFmtsAndObjs[i].back().first );
     379                 :          0 :             SdrObject* pObj( pFmtsAndObjs[i].back().second );
     380                 :          0 :             pFmtsAndObjs[i].pop_back();
     381                 :            : 
     382         [ #  # ]:          0 :             SwDrawContact* pContact = new SwDrawContact( pFmt, pObj );
     383                 :          0 :             pContact->MoveObjToVisibleLayer( pObj );
     384                 :          0 :             pContact->ConnectToLayout();
     385                 :          0 :             lcl_AdjustPositioningAttr( pFmt, *pObj );
     386                 :            : 
     387         [ #  # ]:          0 :             if ( bUndo )
     388                 :            :             {
     389                 :          0 :                 pUndo->AddFmtAndObj( pFmt, pObj );
     390                 :            :             }
     391                 :            :         }
     392                 :            :     }
     393 [ #  # ][ #  # ]:          0 :     delete [] pFmtsAndObjs;
     394                 :          0 : }
     395                 :            : 
     396                 :            : /*************************************************************************
     397                 :            : |*
     398                 :            : |*  SwDoc::DeleteSelection()
     399                 :            : |*
     400                 :            : |*************************************************************************/
     401                 :            : 
     402                 :          0 : sal_Bool SwDoc::DeleteSelection( SwDrawView& rDrawView )
     403                 :            : {
     404                 :          0 :     sal_Bool bCallBase = sal_False;
     405                 :          0 :     const SdrMarkList &rMrkList = rDrawView.GetMarkedObjectList();
     406         [ #  # ]:          0 :     if( rMrkList.GetMarkCount() )
     407                 :            :     {
     408                 :          0 :         GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL);
     409                 :            :         sal_uInt16 i;
     410                 :          0 :         sal_Bool bDelMarked = sal_True;
     411                 :            : 
     412         [ #  # ]:          0 :         if( 1 == rMrkList.GetMarkCount() )
     413                 :            :         {
     414                 :          0 :             SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
     415         [ #  # ]:          0 :             if( pObj->ISA(SwVirtFlyDrawObj) )
     416                 :            :             {
     417                 :            :                 SwFlyFrmFmt* pFrmFmt = (SwFlyFrmFmt*)
     418                 :          0 :                     ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm()->GetFmt();
     419         [ #  # ]:          0 :                 if( pFrmFmt )
     420                 :            :                 {
     421                 :          0 :                     DelLayoutFmt( pFrmFmt );
     422                 :          0 :                     bDelMarked = sal_False;
     423                 :            :                 }
     424                 :            :             }
     425                 :            :         }
     426                 :            : 
     427         [ #  # ]:          0 :         for( i = 0; i < rMrkList.GetMarkCount(); ++i )
     428                 :            :         {
     429                 :          0 :             SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
     430         [ #  # ]:          0 :             if( !pObj->ISA(SwVirtFlyDrawObj) )
     431                 :            :             {
     432                 :          0 :                 SwDrawContact *pC = (SwDrawContact*)GetUserCall(pObj);
     433                 :          0 :                 SwDrawFrmFmt *pFrmFmt = (SwDrawFrmFmt*)pC->GetFmt();
     434         [ #  # ]:          0 :                 if( pFrmFmt &&
           [ #  #  #  # ]
     435                 :          0 :                     FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId() )
     436                 :            :                 {
     437                 :          0 :                     rDrawView.MarkObj( pObj, rDrawView.Imp().GetPageView(), sal_True );
     438                 :          0 :                     --i;
     439                 :          0 :                     DelLayoutFmt( pFrmFmt );
     440                 :            :                 }
     441                 :            :             }
     442                 :            :         }
     443                 :            : 
     444 [ #  # ][ #  # ]:          0 :         if( rMrkList.GetMarkCount() && bDelMarked )
                 [ #  # ]
     445                 :            :         {
     446                 :          0 :             SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
     447         [ #  # ]:          0 :             if( !pObj->GetUpGroup() )
     448                 :            :             {
     449                 :            :                 SwUndoDrawDelete *const pUndo =
     450                 :          0 :                     (!GetIDocumentUndoRedo().DoesUndo())
     451                 :            :                         ? 0
     452 [ #  # ][ #  # ]:          0 :                             : new SwUndoDrawDelete( (sal_uInt16)rMrkList.GetMarkCount() );
     453                 :            : 
     454                 :            :                 // Destroy ContactObjects, save formats.
     455         [ #  # ]:          0 :                 for( i = 0; i < rMrkList.GetMarkCount(); ++i )
     456                 :            :                 {
     457                 :          0 :                     const SdrMark& rMark = *rMrkList.GetMark( i );
     458                 :          0 :                     pObj = rMark.GetMarkedSdrObj();
     459                 :          0 :                     SwDrawContact *pContact = (SwDrawContact*)pObj->GetUserCall();
     460         [ #  # ]:          0 :                     if( pContact ) // of course not for grouped objects
     461                 :            :                     {
     462                 :          0 :                         SwDrawFrmFmt *pFmt = (SwDrawFrmFmt*)pContact->GetFmt();
     463                 :            :                         // before delete of selection is performed, marked
     464                 :            :                         // <SwDrawVirtObj>-objects have to be replaced by its
     465                 :            :                         // reference objects.  Thus, assert, if a
     466                 :            :                         // <SwDrawVirt>-object is found in the mark list.
     467                 :          0 :                         if ( pObj->ISA(SwDrawVirtObj) )
     468                 :            :                         {
     469                 :            :                             OSL_FAIL( "<SwDrawVirtObj> is still marked for delete. application will crash!" );
     470                 :            :                         }
     471                 :            :                         // Deletes itself!
     472                 :          0 :                         pContact->Changed(*pObj, SDRUSERCALL_DELETE, pObj->GetLastBoundRect() );
     473                 :          0 :                         pObj->SetUserCall( 0 );
     474                 :            : 
     475         [ #  # ]:          0 :                         if( pUndo )
     476                 :          0 :                             pUndo->AddObj( i, pFmt, rMark );
     477                 :            :                         else
     478                 :          0 :                             DelFrmFmt( pFmt );
     479                 :            :                     }
     480                 :            :                 }
     481                 :            : 
     482         [ #  # ]:          0 :                 if( pUndo )
     483                 :            :                 {
     484                 :          0 :                     GetIDocumentUndoRedo().AppendUndo( pUndo );
     485                 :            :                 }
     486                 :            :             }
     487                 :          0 :             bCallBase = sal_True;
     488                 :            :         }
     489                 :          0 :         SetModified();
     490                 :            : 
     491                 :          0 :         GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
     492                 :            :     }
     493                 :            : 
     494                 :          0 :     return bCallBase;
     495                 :            : }
     496                 :            : 
     497                 :            : /*************************************************************************
     498                 :            : |*
     499                 :            : |*  SwDoc::DeleteSelection()
     500                 :            : |*
     501                 :            : |*************************************************************************/
     502                 :            : 
     503                 :          3 : _ZSortFly::_ZSortFly( const SwFrmFmt* pFrmFmt, const SwFmtAnchor* pFlyAn,
     504                 :            :                       sal_uInt32 nArrOrdNum )
     505                 :          3 :     : pFmt( pFrmFmt ), pAnchor( pFlyAn ), nOrdNum( nArrOrdNum )
     506                 :            : {
     507                 :            :     // #i11176#
     508                 :            :     // This also needs to work when no layout exists. Thus, for
     509                 :            :     // FlyFrames an alternative method is used now in that case.
     510         [ -  + ]:          3 :     if( RES_FLYFRMFMT == pFmt->Which() )
     511                 :            :     {
     512         [ #  # ]:          0 :         if( pFmt->getIDocumentLayoutAccess()->GetCurrentViewShell() )   //swmod 071107//swmod 071225
     513                 :            :         {
     514                 :            :             // See if there is an SdrObject for it
     515                 :          0 :             SwFlyFrm* pFly = SwIterator<SwFlyFrm,SwFmt>::FirstElement( *pFrmFmt );
     516         [ #  # ]:          0 :             if( pFly )
     517                 :          0 :                 nOrdNum = pFly->GetVirtDrawObj()->GetOrdNum();
     518                 :            :         }
     519                 :            :         else
     520                 :            :         {
     521                 :            :             // See if there is an SdrObject for it
     522                 :          0 :             SwFlyDrawContact* pContact = SwIterator<SwFlyDrawContact,SwFmt>::FirstElement( *pFrmFmt );
     523         [ #  # ]:          0 :             if( pContact )
     524                 :          0 :                 nOrdNum = pContact->GetMaster()->GetOrdNum();
     525                 :            :         }
     526                 :            :     }
     527         [ +  - ]:          3 :     else if( RES_DRAWFRMFMT == pFmt->Which() )
     528                 :            :     {
     529                 :            :             // See if there is an SdrObject for it
     530                 :          3 :             SwDrawContact* pContact = SwIterator<SwDrawContact,SwFmt>::FirstElement( *pFrmFmt );
     531         [ +  - ]:          3 :             if( pContact )
     532                 :          3 :                 nOrdNum = pContact->GetMaster()->GetOrdNum();
     533                 :            :     }
     534                 :            :     else {
     535                 :            :         OSL_ENSURE( !this, "was ist das fuer ein Format?" );
     536                 :            :     }
     537                 :          3 : }
     538                 :            : 
     539                 :            : /*************************************************************************/
     540                 :            : // Is also called by the Sw3 Reader, if there was an error when reading the
     541                 :            : // drawing layer. If it is called by the Sw3 Reader the layer is rebuilt
     542                 :            : // from scratch.
     543                 :            : 
     544                 :            : #include <svx/sxenditm.hxx>
     545                 :            : 
     546                 :       1386 : void SwDoc::InitDrawModel()
     547                 :            : {
     548                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722",  "SwDoc::InitDrawModel" );
     549                 :            : 
     550                 :            :     // !! Attention: there is similar code in the Sw3 Reader (sw3imp.cxx) that
     551                 :            :     // also has to be maintained!!
     552         [ -  + ]:       1386 :     if ( pDrawModel )
     553         [ #  # ]:          0 :         ReleaseDrawModel();
     554                 :            : 
     555                 :            :     // Setup DrawPool and EditEnginePool. Ownership is ours and only gets passed
     556                 :            :     // to the Drawing.
     557                 :            :     // The pools are destroyed in the ReleaseDrawModel.
     558                 :            :     // for loading the drawing items. This must be loaded without RefCounts!
     559 [ +  - ][ +  - ]:       1386 :     SfxItemPool *pSdrPool = new SdrItemPool( &GetAttrPool() );
     560                 :            :     // change DefaultItems for the SdrEdgeObj distance items to TWIPS.
     561         [ +  - ]:       1386 :     if(pSdrPool)
     562                 :            :     {
     563                 :       1386 :         const long nDefEdgeDist = ((500 * 72) / 127); // 1/100th mm in twips
     564 [ +  - ][ +  - ]:       1386 :         pSdrPool->SetPoolDefaultItem(SdrEdgeNode1HorzDistItem(nDefEdgeDist));
                 [ +  - ]
     565 [ +  - ][ +  - ]:       1386 :         pSdrPool->SetPoolDefaultItem(SdrEdgeNode1VertDistItem(nDefEdgeDist));
                 [ +  - ]
     566 [ +  - ][ +  - ]:       1386 :         pSdrPool->SetPoolDefaultItem(SdrEdgeNode2HorzDistItem(nDefEdgeDist));
                 [ +  - ]
     567 [ +  - ][ +  - ]:       1386 :         pSdrPool->SetPoolDefaultItem(SdrEdgeNode2VertDistItem(nDefEdgeDist));
                 [ +  - ]
     568                 :            : 
     569                 :            :         // #i33700#
     570                 :            :         // Set shadow distance defaults as PoolDefaultItems. Details see bug.
     571 [ +  - ][ +  - ]:       1386 :         pSdrPool->SetPoolDefaultItem(SdrShadowXDistItem((300 * 72) / 127));
                 [ +  - ]
     572 [ +  - ][ +  - ]:       1386 :         pSdrPool->SetPoolDefaultItem(SdrShadowYDistItem((300 * 72) / 127));
                 [ +  - ]
     573                 :            :     }
     574         [ +  - ]:       1386 :     SfxItemPool *pEEgPool = EditEngine::CreatePool( sal_False );
     575         [ +  - ]:       1386 :     pSdrPool->SetSecondaryPool( pEEgPool );
     576 [ +  - ][ +  - ]:       1386 :      if ( !GetAttrPool().GetFrozenIdRanges () )
     577         [ +  - ]:       1386 :         GetAttrPool().FreezeIdRanges();
     578                 :            :     else
     579         [ #  # ]:          0 :         pSdrPool->FreezeIdRanges();
     580                 :            : 
     581                 :            :     // set FontHeight pool defaults without changing static SdrEngineDefaults
     582 [ +  - ][ +  - ]:       1386 :      GetAttrPool().SetPoolDefaultItem(SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT ));
                 [ +  - ]
     583                 :            : 
     584                 :            :     RTL_LOGFILE_CONTEXT_TRACE( aLog, "before create DrawDocument" );
     585                 :            :     // The document owns the SdrModel. We always have two layers and one page.
     586 [ +  - ][ +  - ]:       1386 :     pDrawModel = new SwDrawDocument( this );
     587                 :            : 
     588 [ +  - ][ +  - ]:       1386 :     pDrawModel->EnableUndo( GetIDocumentUndoRedo().DoesUndo() );
                 [ +  - ]
     589                 :            : 
     590         [ +  - ]:       1386 :     String sLayerNm;
     591         [ +  - ]:       1386 :     sLayerNm.AssignAscii(RTL_CONSTASCII_STRINGPARAM("Hell" ));
     592         [ +  - ]:       1386 :     nHell   = pDrawModel->GetLayerAdmin().NewLayer( sLayerNm )->GetID();
     593                 :            : 
     594         [ +  - ]:       1386 :     sLayerNm.AssignAscii(RTL_CONSTASCII_STRINGPARAM("Heaven" ));
     595         [ +  - ]:       1386 :     nHeaven = pDrawModel->GetLayerAdmin().NewLayer( sLayerNm )->GetID();
     596                 :            : 
     597         [ +  - ]:       1386 :     sLayerNm.AssignAscii(RTL_CONSTASCII_STRINGPARAM("Controls" ));
     598         [ +  - ]:       1386 :     nControls = pDrawModel->GetLayerAdmin().NewLayer( sLayerNm )->GetID();
     599                 :            : 
     600                 :            :     // add invisible layers corresponding to the visible ones.
     601                 :            :     {
     602         [ +  - ]:       1386 :         sLayerNm.AssignAscii(RTL_CONSTASCII_STRINGPARAM("InvisibleHell" ));
     603         [ +  - ]:       1386 :         nInvisibleHell   = pDrawModel->GetLayerAdmin().NewLayer( sLayerNm )->GetID();
     604                 :            : 
     605         [ +  - ]:       1386 :         sLayerNm.AssignAscii(RTL_CONSTASCII_STRINGPARAM("InvisibleHeaven" ));
     606         [ +  - ]:       1386 :         nInvisibleHeaven = pDrawModel->GetLayerAdmin().NewLayer( sLayerNm )->GetID();
     607                 :            : 
     608         [ +  - ]:       1386 :         sLayerNm.AssignAscii(RTL_CONSTASCII_STRINGPARAM("InvisibleControls" ));
     609         [ +  - ]:       1386 :         nInvisibleControls = pDrawModel->GetLayerAdmin().NewLayer( sLayerNm )->GetID();
     610                 :            :     }
     611                 :            : 
     612         [ +  - ]:       1386 :     SdrPage* pMasterPage = pDrawModel->AllocPage( sal_False );
     613         [ +  - ]:       1386 :     pDrawModel->InsertPage( pMasterPage );
     614                 :            :     RTL_LOGFILE_CONTEXT_TRACE( aLog, "after create DrawDocument" );
     615                 :            : 
     616                 :            :     RTL_LOGFILE_CONTEXT_TRACE( aLog, "before create Spellchecker/Hyphenator" );
     617         [ +  - ]:       1386 :     SdrOutliner& rOutliner = pDrawModel->GetDrawOutliner();
     618         [ +  - ]:       1386 :     uno::Reference< XSpellChecker1 > xSpell = ::GetSpellChecker();
     619         [ +  - ]:       1386 :     rOutliner.SetSpeller( xSpell );
     620         [ +  - ]:       1386 :     uno::Reference<XHyphenator> xHyphenator( ::GetHyphenator() );
     621         [ +  - ]:       1386 :     rOutliner.SetHyphenator( xHyphenator );
     622                 :            :     RTL_LOGFILE_CONTEXT_TRACE( aLog, "after create Spellchecker/Hyphenator" );
     623                 :            : 
     624         [ +  - ]:       1386 :     SetCalcFieldValueHdl(&rOutliner);
     625         [ +  - ]:       1386 :     SetCalcFieldValueHdl(&pDrawModel->GetHitTestOutliner());
     626                 :            : 
     627                 :            :     // Set the LinkManager in the model so that linked graphics can be inserted.
     628                 :            :     // The WinWord import needs it too.
     629         [ +  - ]:       1386 :     pDrawModel->SetLinkManager( &GetLinkManager() );
     630 [ +  - ][ +  - ]:       1386 :     pDrawModel->SetAddExtLeading( get(IDocumentSettingAccess::ADD_EXT_LEADING) );
     631                 :            : 
     632         [ +  - ]:       1386 :     OutputDevice* pRefDev = getReferenceDevice( false );
     633         [ +  + ]:       1386 :     if ( pRefDev )
     634         [ +  - ]:       1319 :         pDrawModel->SetRefDevice( pRefDev );
     635                 :            : 
     636         [ +  - ]:       1386 :     pDrawModel->SetNotifyUndoActionHdl( LINK( this, SwDoc, AddDrawUndo ));
     637         [ +  + ]:       1386 :     if ( pCurrentView )
     638                 :            :     {
     639                 :        746 :         ViewShell* pViewSh = pCurrentView;
     640         [ -  + ]:        746 :         do
     641                 :            :         {
     642         [ +  - ]:        746 :             SwRootFrm* pRoot =  pViewSh->GetLayout();
     643 [ +  - ][ +  - ]:        746 :             if( pRoot && !pRoot->GetDrawPage() )
                 [ +  - ]
     644                 :            :             {
     645                 :            :                 // Disable "multiple layout" for the moment:
     646                 :            :                 // use pMasterPage instead of a new created SdrPage
     647                 :            :                 // pDrawModel->AllocPage( FALSE );
     648                 :            :                 // pDrawModel->InsertPage( pDrawPage );
     649                 :        746 :                 SdrPage* pDrawPage = pMasterPage;
     650                 :        746 :                 pRoot->SetDrawPage( pDrawPage );
     651         [ +  - ]:        746 :                 pDrawPage->SetSize( pRoot->Frm().SSize() );
     652                 :            :             }
     653                 :        746 :             pViewSh = (ViewShell*)pViewSh->GetNext();
     654                 :            :         }while( pViewSh != pCurrentView );
     655                 :            :     }
     656                 :            : 
     657 [ +  - ][ +  - ]:       1386 :     UpdateDrawDefaults();
     658                 :       1386 : }
     659                 :            : 
     660                 :            : /** method to notify drawing page view about the invisible layers */
     661                 :       1337 : void SwDoc::NotifyInvisibleLayers( SdrPageView& _rSdrPageView )
     662                 :            : {
     663         [ +  - ]:       1337 :     String sLayerNm;
     664         [ +  - ]:       1337 :     sLayerNm.AssignAscii(RTL_CONSTASCII_STRINGPARAM("InvisibleHell" ));
     665         [ +  - ]:       1337 :     _rSdrPageView.SetLayerVisible( sLayerNm, sal_False );
     666                 :            : 
     667         [ +  - ]:       1337 :     sLayerNm.AssignAscii(RTL_CONSTASCII_STRINGPARAM("InvisibleHeaven" ));
     668         [ +  - ]:       1337 :     _rSdrPageView.SetLayerVisible( sLayerNm, sal_False );
     669                 :            : 
     670         [ +  - ]:       1337 :     sLayerNm.AssignAscii(RTL_CONSTASCII_STRINGPARAM("InvisibleControls" ));
     671 [ +  - ][ +  - ]:       1337 :     _rSdrPageView.SetLayerVisible( sLayerNm, sal_False );
     672                 :       1337 : }
     673                 :            : 
     674                 :            : /** method to determine, if a layer ID belongs to the visible ones.
     675                 :            : 
     676                 :            :     Note: If given layer ID is unknown, method asserts and returns <false>.
     677                 :            : */
     678                 :      25803 : bool SwDoc::IsVisibleLayerId( const SdrLayerID& _nLayerId ) const
     679                 :            : {
     680                 :            :     bool bRetVal;
     681                 :            : 
     682   [ +  +  +  +  :      52265 :     if ( _nLayerId == GetHeavenId() ||
           +  + ][ +  + ]
     683                 :      13943 :          _nLayerId == GetHellId() ||
     684                 :      12519 :          _nLayerId == GetControlsId() )
     685                 :            :     {
     686                 :      23905 :         bRetVal = true;
     687                 :            :     }
     688   [ +  +  +  +  :       5042 :     else if ( _nLayerId == GetInvisibleHeavenId() ||
           +  - ][ +  - ]
     689                 :       1700 :               _nLayerId == GetInvisibleHellId() ||
     690                 :       1444 :               _nLayerId == GetInvisibleControlsId() )
     691                 :            :     {
     692                 :       1898 :         bRetVal = false;
     693                 :            :     }
     694                 :            :     else
     695                 :            :     {
     696                 :            :         OSL_FAIL( "<SwDoc::IsVisibleLayerId(..)> - unknown layer ID." );
     697                 :          0 :         bRetVal = false;
     698                 :            :     }
     699                 :            : 
     700                 :      25803 :     return bRetVal;
     701                 :            : }
     702                 :            : 
     703                 :            : /** method to determine, if the corresponding visible layer ID for a invisible one.
     704                 :            : 
     705                 :            :     Note: If given layer ID is a visible one, method returns given layer ID.
     706                 :            :     Note: If given layer ID is unknown, method returns given layer ID.
     707                 :            : */
     708                 :          0 : SdrLayerID SwDoc::GetVisibleLayerIdByInvisibleOne( const SdrLayerID& _nInvisibleLayerId )
     709                 :            : {
     710                 :            :     SdrLayerID nVisibleLayerId;
     711                 :            : 
     712         [ #  # ]:          0 :     if ( _nInvisibleLayerId == GetInvisibleHeavenId() )
     713                 :            :     {
     714                 :          0 :         nVisibleLayerId = GetHeavenId();
     715                 :            :     }
     716         [ #  # ]:          0 :     else if ( _nInvisibleLayerId == GetInvisibleHellId() )
     717                 :            :     {
     718                 :          0 :         nVisibleLayerId = GetHellId();
     719                 :            :     }
     720         [ #  # ]:          0 :     else if ( _nInvisibleLayerId == GetInvisibleControlsId() )
     721                 :            :     {
     722                 :          0 :         nVisibleLayerId = GetControlsId();
     723                 :            :     }
     724   [ #  #  #  #  :          0 :     else if ( _nInvisibleLayerId == GetHeavenId() ||
           #  # ][ #  # ]
     725                 :          0 :               _nInvisibleLayerId == GetHellId() ||
     726                 :          0 :               _nInvisibleLayerId == GetControlsId() )
     727                 :            :     {
     728                 :            :         OSL_FAIL( "<SwDoc::GetVisibleLayerIdByInvisibleOne(..)> - given layer ID already an invisible one." );
     729                 :          0 :         nVisibleLayerId = _nInvisibleLayerId;
     730                 :            :     }
     731                 :            :     else
     732                 :            :     {
     733                 :            :         OSL_FAIL( "<SwDoc::GetVisibleLayerIdByInvisibleOne(..)> - given layer ID is unknown." );
     734                 :          0 :         nVisibleLayerId = _nInvisibleLayerId;
     735                 :            :     }
     736                 :            : 
     737                 :          0 :     return nVisibleLayerId;
     738                 :            : }
     739                 :            : 
     740                 :            : /** method to determine, if the corresponding invisible layer ID for a visible one.
     741                 :            : 
     742                 :            :     Note: If given layer ID is a invisible one, method returns given layer ID.
     743                 :            :     Note: If given layer ID is unknown, method returns given layer ID.
     744                 :            : */
     745                 :          0 : SdrLayerID SwDoc::GetInvisibleLayerIdByVisibleOne( const SdrLayerID& _nVisibleLayerId )
     746                 :            : {
     747                 :            :     SdrLayerID nInvisibleLayerId;
     748                 :            : 
     749         [ #  # ]:          0 :     if ( _nVisibleLayerId == GetHeavenId() )
     750                 :            :     {
     751                 :          0 :         nInvisibleLayerId = GetInvisibleHeavenId();
     752                 :            :     }
     753         [ #  # ]:          0 :     else if ( _nVisibleLayerId == GetHellId() )
     754                 :            :     {
     755                 :          0 :         nInvisibleLayerId = GetInvisibleHellId();
     756                 :            :     }
     757         [ #  # ]:          0 :     else if ( _nVisibleLayerId == GetControlsId() )
     758                 :            :     {
     759                 :          0 :         nInvisibleLayerId = GetInvisibleControlsId();
     760                 :            :     }
     761   [ #  #  #  #  :          0 :     else if ( _nVisibleLayerId == GetInvisibleHeavenId() ||
           #  # ][ #  # ]
     762                 :          0 :               _nVisibleLayerId == GetInvisibleHellId() ||
     763                 :          0 :               _nVisibleLayerId == GetInvisibleControlsId() )
     764                 :            :     {
     765                 :            :         OSL_FAIL( "<SwDoc::GetInvisibleLayerIdByVisibleOne(..)> - given layer ID already an invisible one." );
     766                 :          0 :         nInvisibleLayerId = _nVisibleLayerId;
     767                 :            :     }
     768                 :            :     else
     769                 :            :     {
     770                 :            :         OSL_FAIL( "<SwDoc::GetInvisibleLayerIdByVisibleOne(..)> - given layer ID is unknown." );
     771                 :          0 :         nInvisibleLayerId = _nVisibleLayerId;
     772                 :            :     }
     773                 :            : 
     774                 :          0 :     return nInvisibleLayerId;
     775                 :            : }
     776                 :            : 
     777                 :            : /*************************************************************************/
     778                 :            : 
     779                 :            : 
     780                 :       1458 : void SwDoc::ReleaseDrawModel()
     781                 :            : {
     782         [ +  + ]:       1458 :     if ( pDrawModel )
     783                 :            :     {
     784                 :            :         // !! Also maintain the code in the sw3io for inserting documents!!
     785                 :            : 
     786         [ +  - ]:       1297 :         delete pDrawModel; pDrawModel = 0;
     787                 :       1297 :         SfxItemPool *pSdrPool = GetAttrPool().GetSecondaryPool();
     788                 :            : 
     789                 :            :         OSL_ENSURE( pSdrPool, "missing pool" );
     790                 :       1297 :         SfxItemPool *pEEgPool = pSdrPool->GetSecondaryPool();
     791                 :            :         OSL_ENSURE( !pEEgPool->GetSecondaryPool(), "I don't accept additional pools");
     792                 :       1297 :         pSdrPool->Delete();                 // First have the items destroyed,
     793                 :            :                                             // then destroy the chain!
     794                 :       1297 :         GetAttrPool().SetSecondaryPool( 0 );    // This one's a must!
     795                 :       1297 :         pSdrPool->SetSecondaryPool( 0 );    // That one's safer
     796                 :       1297 :         SfxItemPool::Free(pSdrPool);
     797                 :       1297 :         SfxItemPool::Free(pEEgPool);
     798                 :            :     }
     799                 :       1458 : }
     800                 :            : 
     801                 :            : /*************************************************************************/
     802                 :            : 
     803                 :            : 
     804                 :       1386 : SdrModel* SwDoc::_MakeDrawModel()
     805                 :            : {
     806                 :            :     OSL_ENSURE( !pDrawModel, "_MakeDrawModel: Why?" );
     807                 :       1386 :     InitDrawModel();
     808         [ +  + ]:       1386 :     if ( pCurrentView )
     809                 :            :     {
     810                 :        746 :         ViewShell* pTmp = pCurrentView;
     811         [ -  + ]:        746 :         do
     812                 :            :         {
     813                 :        746 :             pTmp->MakeDrawView();
     814                 :        746 :             pTmp = (ViewShell*) pTmp->GetNext();
     815                 :            :         } while ( pTmp != pCurrentView );
     816                 :            : 
     817                 :            :         // Broadcast, so that the FormShell can be connected to the DrawView
     818         [ +  - ]:        746 :         if( GetDocShell() )
     819                 :            :         {
     820         [ +  - ]:        746 :             SfxSimpleHint aHnt( SW_BROADCAST_DRAWVIEWS_CREATED );
     821 [ +  - ][ +  - ]:        746 :             GetDocShell()->Broadcast( aHnt );
     822                 :            :         }
     823                 :            :     }   //swmod 071029//swmod 071225
     824                 :       1386 :     return pDrawModel;
     825                 :            : }
     826                 :            : 
     827                 :            : /*************************************************************************/
     828                 :            : 
     829                 :       1297 : void SwDoc::DrawNotifyUndoHdl()
     830                 :            : {
     831                 :       1297 :     pDrawModel->SetNotifyUndoActionHdl( Link() );
     832                 :       1297 : }
     833                 :            : 
     834                 :            : /*************************************************************************
     835                 :            : *
     836                 :            : * In the Outliner, set a link to the method for field display in edit objects.
     837                 :            : *
     838                 :            : *************************************************************************/
     839                 :            : 
     840                 :       2814 : void SwDoc::SetCalcFieldValueHdl(Outliner* pOutliner)
     841                 :            : {
     842                 :       2814 :     pOutliner->SetCalcFieldValueHdl(LINK(this, SwDoc, CalcFieldValueHdl));
     843                 :       2814 : }
     844                 :            : 
     845                 :            : /*************************************************************************
     846                 :            : |*
     847                 :            : |* Recognise fields/URLs in the Outliner and set how they are displayed.
     848                 :            : |*
     849                 :            : \************************************************************************/
     850                 :            : 
     851                 :          0 : IMPL_LINK(SwDoc, CalcFieldValueHdl, EditFieldInfo*, pInfo)
     852                 :            : {
     853         [ #  # ]:          0 :     if (pInfo)
     854                 :            :     {
     855                 :          0 :         const SvxFieldItem& rField = pInfo->GetField();
     856                 :          0 :         const SvxFieldData* pField = rField.GetField();
     857                 :            : 
     858 [ #  # ][ #  # ]:          0 :         if (pField && pField->ISA(SvxDateField))
                 [ #  # ]
     859                 :            :         {
     860                 :            :             /******************************************************************
     861                 :            :             * Date field
     862                 :            :             ******************************************************************/
     863                 :            :             pInfo->SetRepresentation(
     864                 :            :                 ((const SvxDateField*) pField)->GetFormatted(
     865 [ #  # ][ #  # ]:          0 :                         *GetNumberFormatter( sal_True ), LANGUAGE_SYSTEM) );
                 [ #  # ]
     866                 :            :         }
     867 [ #  # ][ #  # ]:          0 :         else if (pField && pField->ISA(SvxURLField))
                 [ #  # ]
     868                 :            :         {
     869                 :            :             /******************************************************************
     870                 :            :             * URL field
     871                 :            :             ******************************************************************/
     872                 :            : 
     873      [ #  #  # ]:          0 :             switch ( ((const SvxURLField*) pField)->GetFormat() )
     874                 :            :             {
     875                 :            :                 case SVXURLFORMAT_APPDEFAULT: //!!! Can be set in App???
     876                 :            :                 case SVXURLFORMAT_REPR:
     877                 :            :                 {
     878                 :            :                     pInfo->SetRepresentation(
     879 [ #  # ][ #  # ]:          0 :                         ((const SvxURLField*)pField)->GetRepresentation());
                 [ #  # ]
     880                 :            :                 }
     881                 :          0 :                 break;
     882                 :            : 
     883                 :            :                 case SVXURLFORMAT_URL:
     884                 :            :                 {
     885                 :            :                     pInfo->SetRepresentation(
     886 [ #  # ][ #  # ]:          0 :                         ((const SvxURLField*)pField)->GetURL());
                 [ #  # ]
     887                 :            :                 }
     888                 :          0 :                 break;
     889                 :            :             }
     890                 :            : 
     891                 :            :             sal_uInt16 nChrFmt;
     892                 :            : 
     893 [ #  # ][ #  # ]:          0 :             if (IsVisitedURL(((const SvxURLField*)pField)->GetURL()))
         [ #  # ][ #  # ]
     894                 :          0 :                 nChrFmt = RES_POOLCHR_INET_VISIT;
     895                 :            :             else
     896                 :          0 :                 nChrFmt = RES_POOLCHR_INET_NORMAL;
     897                 :            : 
     898         [ #  # ]:          0 :             SwFmt *pFmt = GetCharFmtFromPool(nChrFmt);
     899                 :            : 
     900                 :          0 :             Color aColor(COL_LIGHTBLUE);
     901         [ #  # ]:          0 :             if (pFmt)
     902         [ #  # ]:          0 :                 aColor = pFmt->GetColor().GetValue();
     903                 :            : 
     904         [ #  # ]:          0 :             pInfo->SetTxtColor(aColor);
     905                 :            :         }
     906 [ #  # ][ #  # ]:          0 :         else if (pField && pField->ISA(SdrMeasureField))
                 [ #  # ]
     907                 :            :         {
     908                 :            :             /******************************************************************
     909                 :            :             * Measure field
     910                 :            :             ******************************************************************/
     911                 :          0 :             pInfo->ClearFldColor();
     912                 :            :         }
     913 [ #  # ][ #  # ]:          0 :         else if ( pField && pField->ISA(SvxExtTimeField))
                 [ #  # ]
     914                 :            :         {
     915                 :            :             /******************************************************************
     916                 :            :             * Time field
     917                 :            :             ******************************************************************/
     918                 :            :             pInfo->SetRepresentation(
     919                 :            :                 ((const SvxExtTimeField*) pField)->GetFormatted(
     920 [ #  # ][ #  # ]:          0 :                         *GetNumberFormatter( sal_True ), LANGUAGE_SYSTEM) );
                 [ #  # ]
     921                 :            :         }
     922                 :            :         else
     923                 :            :         {
     924                 :            :             OSL_FAIL("unknown field command");
     925 [ #  # ][ #  # ]:          0 :             pInfo->SetRepresentation( rtl::OUString( '?' ) );
                 [ #  # ]
     926                 :            :         }
     927                 :            :     }
     928                 :            : 
     929                 :          0 :     return(0);
     930                 :            : }
     931                 :            : 
     932                 :            : /* TFFDI: The functions formerly declared 'inline'
     933                 :            :  */
     934                 :          0 : const SdrModel* SwDoc::GetDrawModel() const { return pDrawModel; }
     935                 :      41542 : SdrModel* SwDoc::GetDrawModel() { return pDrawModel; }
     936                 :      67893 : SdrLayerID SwDoc::GetHeavenId() const { return nHeaven; }
     937                 :      82587 : SdrLayerID SwDoc::GetHellId() const { return nHell; }
     938                 :      17171 : SdrLayerID SwDoc::GetControlsId() const { return nControls;   }
     939                 :       6307 : SdrLayerID SwDoc::GetInvisibleHeavenId() const { return nInvisibleHeaven; }
     940                 :       6282 : SdrLayerID SwDoc::GetInvisibleHellId() const { return nInvisibleHell; }
     941                 :       7173 : SdrLayerID SwDoc::GetInvisibleControlsId() const { return nInvisibleControls; }
     942         [ +  + ]:       3274 : SdrModel* SwDoc::GetOrCreateDrawModel() { return GetDrawModel() ? GetDrawModel() : _MakeDrawModel(); }
     943                 :            : 
     944                 :            : // #i62875#
     945                 :            : namespace docfunc
     946                 :            : {
     947                 :          0 :     bool ExistsDrawObjs( SwDoc& p_rDoc )
     948                 :            :     {
     949                 :          0 :         bool bExistsDrawObjs( false );
     950                 :            : 
     951   [ #  #  #  # ]:          0 :         if ( p_rDoc.GetDrawModel() &&
                 [ #  # ]
     952                 :          0 :              p_rDoc.GetDrawModel()->GetPage( 0 ) )
     953                 :            :         {
     954 [ #  # ][ #  # ]:          0 :             const SdrPage& rSdrPage( *(p_rDoc.GetDrawModel()->GetPage( 0 )) );
     955                 :            : 
     956         [ #  # ]:          0 :             SdrObjListIter aIter( rSdrPage, IM_FLAT );
     957         [ #  # ]:          0 :             while( aIter.IsMore() )
     958                 :            :             {
     959         [ #  # ]:          0 :                 SdrObject* pObj( aIter.Next() );
     960 [ #  # ][ #  # ]:          0 :                 if ( !dynamic_cast<SwVirtFlyDrawObj*>(pObj) &&
         [ #  # ][ #  # ]
     961         [ #  # ]:          0 :                      !dynamic_cast<SwFlyDrawObj*>(pObj) )
     962                 :            :                 {
     963                 :          0 :                     bExistsDrawObjs = true;
     964                 :          0 :                     break;
     965                 :            :                 }
     966                 :          0 :             }
     967                 :            :         }
     968                 :            : 
     969                 :          0 :         return bExistsDrawObjs;
     970                 :            :     }
     971                 :            : 
     972                 :          0 :     bool AllDrawObjsOnPage( SwDoc& p_rDoc )
     973                 :            :     {
     974                 :          0 :         bool bAllDrawObjsOnPage( true );
     975                 :            : 
     976   [ #  #  #  # ]:          0 :         if ( p_rDoc.GetDrawModel() &&
                 [ #  # ]
     977                 :          0 :              p_rDoc.GetDrawModel()->GetPage( 0 ) )
     978                 :            :         {
     979 [ #  # ][ #  # ]:          0 :             const SdrPage& rSdrPage( *(p_rDoc.GetDrawModel()->GetPage( 0 )) );
     980                 :            : 
     981         [ #  # ]:          0 :             SdrObjListIter aIter( rSdrPage, IM_FLAT );
     982         [ #  # ]:          0 :             while( aIter.IsMore() )
     983                 :            :             {
     984         [ #  # ]:          0 :                 SdrObject* pObj( aIter.Next() );
     985 [ #  # ][ #  # ]:          0 :                 if ( !dynamic_cast<SwVirtFlyDrawObj*>(pObj) &&
         [ #  # ][ #  # ]
     986         [ #  # ]:          0 :                      !dynamic_cast<SwFlyDrawObj*>(pObj) )
     987                 :            :                 {
     988                 :            :                     SwDrawContact* pDrawContact =
     989 [ #  # ][ #  # ]:          0 :                             dynamic_cast<SwDrawContact*>(::GetUserCall( pObj ));
     990         [ #  # ]:          0 :                     if ( pDrawContact )
     991                 :            :                     {
     992                 :            :                         SwAnchoredDrawObject* pAnchoredDrawObj =
     993 [ #  # ][ #  # ]:          0 :                             dynamic_cast<SwAnchoredDrawObject*>(pDrawContact->GetAnchoredObj( pObj ));
     994                 :            : 
     995                 :            :                         // error handling
     996                 :            :                         {
     997         [ #  # ]:          0 :                             if ( !pAnchoredDrawObj )
     998                 :            :                             {
     999                 :            :                                 OSL_FAIL( "<docfunc::AllDrawObjsOnPage() - missing anchored draw object" );
    1000                 :          0 :                                 bAllDrawObjsOnPage = false;
    1001                 :          0 :                                 break;
    1002                 :            :                             }
    1003                 :            :                         }
    1004                 :            : 
    1005         [ #  # ]:          0 :                         if ( pAnchoredDrawObj->NotYetPositioned() )
    1006                 :            :                         {
    1007                 :            :                             // The drawing object isn't yet layouted.
    1008                 :            :                             // Thus, it isn't known, if all drawing objects are on page.
    1009                 :          0 :                             bAllDrawObjsOnPage = false;
    1010                 :          0 :                             break;
    1011                 :            :                         }
    1012 [ #  # ][ #  # ]:          0 :                         else if ( pAnchoredDrawObj->IsOutsidePage() )
    1013                 :            :                         {
    1014                 :          0 :                             bAllDrawObjsOnPage = false;
    1015                 :          0 :                             break;
    1016                 :            :                         }
    1017                 :            :                     }
    1018                 :            :                     else
    1019                 :            :                     {
    1020                 :            :                         // contact object of drawing object doesn't exists.
    1021                 :            :                         // Thus, the drawing object isn't yet positioned.
    1022                 :            :                         // Thus, it isn't known, if all drawing objects are on page.
    1023                 :          0 :                         bAllDrawObjsOnPage = false;
    1024                 :          0 :                         break;
    1025                 :            :                     }
    1026                 :            :                 }
    1027                 :          0 :             }
    1028                 :            :         }
    1029                 :            : 
    1030                 :          0 :         return bAllDrawObjsOnPage;
    1031                 :            :     }
    1032                 :            : }
    1033                 :            : 
    1034                 :       1487 : void SwDoc::SetDrawDefaults()
    1035                 :            : {
    1036                 :       1487 :     mbSetDrawDefaults = true;
    1037                 :       1487 :     UpdateDrawDefaults();
    1038                 :       1487 : }
    1039                 :            : 
    1040                 :       2873 : void SwDoc::UpdateDrawDefaults()
    1041                 :            : {
    1042                 :            :     // drawing layer defaults that are set for new documents (if InitNew was called)
    1043 [ +  + ][ +  + ]:       2873 :     if ( pDrawModel && mbSetDrawDefaults )
    1044                 :       1323 :         pDrawModel->SetDrawingLayerPoolDefaults();
    1045                 :       2873 : }
    1046                 :            : 
    1047                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10