LCOV - code coverage report
Current view: top level - sw/source/core/doc - docdraw.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 83 275 30.2 %
Date: 2014-11-03 Functions: 8 12 66.7 %
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 <hintids.hxx>
      21             : #include <vcl/outdev.hxx>
      22             : #include <sfx2/printer.hxx>
      23             : #include <editeng/eeitem.hxx>
      24             : #include <editeng/flditem.hxx>
      25             : #include <editeng/editeng.hxx>
      26             : #include <svx/svdoutl.hxx>
      27             : #include <editeng/colritem.hxx>
      28             : #include <svx/svdpage.hxx>
      29             : #include <svx/svdogrp.hxx>
      30             : #include <editeng/langitem.hxx>
      31             : #include <editeng/unolingu.hxx>
      32             : #include <editeng/measfld.hxx>
      33             : #include <svx/svdpool.hxx>
      34             : #include <fmtanchr.hxx>
      35             : #include <charatr.hxx>
      36             : #include <frmfmt.hxx>
      37             : #include <charfmt.hxx>
      38             : #include <viewimp.hxx>
      39             : #include <swhints.hxx>
      40             : #include <doc.hxx>
      41             : #include <IDocumentUndoRedo.hxx>
      42             : #include <DocumentSettingManager.hxx>
      43             : #include <IDocumentDeviceAccess.hxx>
      44             : #include <IDocumentDrawModelAccess.hxx>
      45             : #include <IDocumentState.hxx>
      46             : #include <IDocumentLayoutAccess.hxx>
      47             : #include <IDocumentStylePoolAccess.hxx>
      48             : #include <docsh.hxx>
      49             : #include <rootfrm.hxx>
      50             : #include <poolfmt.hxx>
      51             : #include <viewsh.hxx>
      52             : #include <drawdoc.hxx>
      53             : #include <UndoDraw.hxx>
      54             : #include <swundo.hxx>
      55             : #include <dcontact.hxx>
      56             : #include <dview.hxx>
      57             : #include <mvsave.hxx>
      58             : #include <flyfrm.hxx>
      59             : #include <dflyobj.hxx>
      60             : #include <svx/svdetc.hxx>
      61             : #include <editeng/fhgtitem.hxx>
      62             : #include <svx/svdpagv.hxx>
      63             : #include <txtfrm.hxx>
      64             : #include <editeng/frmdiritem.hxx>
      65             : #include <fmtornt.hxx>
      66             : #include <svx/svditer.hxx>
      67             : 
      68             : #include <vector>
      69             : #include <switerator.hxx>
      70             : 
      71             : using namespace ::com::sun::star;
      72             : using namespace ::com::sun::star::linguistic2;
      73             : 
      74             : /** local method to determine positioning and alignment attributes for a drawing
      75             :  *  object, which is newly connected to the layout.
      76             :  *
      77             :  * Used for a newly formed group object <SwDoc::GroupSelection(..)>
      78             :  * and the members of a destroyed group <SwDoc::UnGroupSelection(..)>
      79             :  */
      80           0 : static void lcl_AdjustPositioningAttr( SwDrawFrmFmt* _pFrmFmt,
      81             :                                 const SdrObject& _rSdrObj )
      82             : {
      83           0 :     const SwContact* pContact = GetUserCall( &_rSdrObj );
      84             :     OSL_ENSURE( pContact, "<lcl_AdjustPositioningAttr(..)> - missing contact object." );
      85             : 
      86             :     // determine position of new group object relative to its anchor frame position
      87           0 :     SwTwips nHoriRelPos = 0;
      88           0 :     SwTwips nVertRelPos = 0;
      89             :     {
      90           0 :         const SwFrm* pAnchorFrm = pContact->GetAnchoredObj( &_rSdrObj )->GetAnchorFrm();
      91             :         OSL_ENSURE( !pAnchorFrm ||
      92             :                 !pAnchorFrm->IsTxtFrm() ||
      93             :                 !static_cast<const SwTxtFrm*>(pAnchorFrm)->IsFollow(),
      94             :                 "<lcl_AdjustPositioningAttr(..)> - anchor frame is a follow. Please inform OD." );
      95           0 :         bool bVert = false;
      96           0 :         bool bR2L = false;
      97             :         // #i45952# - use anchor position of anchor frame, if it exist.
      98           0 :         Point aAnchorPos;
      99           0 :         if ( pAnchorFrm )
     100             :         {
     101             :             // #i45952#
     102           0 :             aAnchorPos = pAnchorFrm->GetFrmAnchorPos( ::HasWrap( &_rSdrObj ) );
     103           0 :             bVert = pAnchorFrm->IsVertical();
     104           0 :             bR2L = pAnchorFrm->IsRightToLeft();
     105             :         }
     106             :         else
     107             :         {
     108             :             // #i45952#
     109           0 :             aAnchorPos = _rSdrObj.GetAnchorPos();
     110             :             // If no anchor frame exist - e.g. because no layout exists - the
     111             :             // default layout direction is taken.
     112             :             const SvxFrameDirectionItem* pDirItem =
     113           0 :                 static_cast<const SvxFrameDirectionItem*>(&(_pFrmFmt->GetAttrSet().GetPool()->GetDefaultItem( RES_FRAMEDIR )));
     114           0 :             switch ( pDirItem->GetValue() )
     115             :             {
     116             :                 case FRMDIR_VERT_TOP_LEFT:
     117             :                 {
     118             :                     // vertical from left-to-right
     119           0 :                     bVert = true;
     120           0 :                     bR2L = true;
     121             :                     OSL_FAIL( "<lcl_AdjustPositioningAttr(..)> - vertical from left-to-right not supported." );
     122             :                 }
     123           0 :                 break;
     124             :                 case FRMDIR_VERT_TOP_RIGHT:
     125             :                 {
     126             :                     // vertical from right-to-left
     127           0 :                     bVert = true;
     128           0 :                     bR2L = false;
     129             :                 }
     130           0 :                 break;
     131             :                 case FRMDIR_HORI_RIGHT_TOP:
     132             :                 {
     133             :                     // horizontal from right-to-left
     134           0 :                     bVert = false;
     135           0 :                     bR2L = true;
     136             :                 }
     137           0 :                 break;
     138             :                 case FRMDIR_HORI_LEFT_TOP:
     139             :                 {
     140             :                     // horizontal from left-to-right
     141           0 :                     bVert = false;
     142           0 :                     bR2L = false;
     143             :                 }
     144           0 :                 break;
     145             :             }
     146             : 
     147             :         }
     148             :         // use geometry of drawing object
     149           0 :         const SwRect aObjRect = _rSdrObj.GetSnapRect();
     150             : 
     151           0 :         if ( bVert )
     152             :         {
     153           0 :             if ( bR2L ) {
     154             :                   //FRMDIR_VERT_TOP_LEFT
     155           0 :                   nHoriRelPos = aObjRect.Left() - aAnchorPos.getX();
     156           0 :                   nVertRelPos = aObjRect.Top() - aAnchorPos.getY();
     157             :             } else {
     158             :                 //FRMDIR_VERT_TOP_RIGHT
     159           0 :                 nHoriRelPos = aObjRect.Top() - aAnchorPos.getY();
     160           0 :                 nVertRelPos = aAnchorPos.getX() - aObjRect.Right();
     161             :             }
     162             :         }
     163           0 :         else if ( bR2L )
     164             :         {
     165           0 :             nHoriRelPos = aAnchorPos.getX() - aObjRect.Right();
     166           0 :             nVertRelPos = aObjRect.Top() - aAnchorPos.getY();
     167             :         }
     168             :         else
     169             :         {
     170           0 :             nHoriRelPos = aObjRect.Left() - aAnchorPos.getX();
     171           0 :             nVertRelPos = aObjRect.Top() - aAnchorPos.getY();
     172             :         }
     173             :     }
     174             : 
     175           0 :     _pFrmFmt->SetFmtAttr( SwFmtHoriOrient( nHoriRelPos, text::HoriOrientation::NONE, text::RelOrientation::FRAME ) );
     176           0 :     _pFrmFmt->SetFmtAttr( SwFmtVertOrient( nVertRelPos, text::VertOrientation::NONE, text::RelOrientation::FRAME ) );
     177             :     // #i44334#, #i44681# - positioning attributes already set
     178           0 :     _pFrmFmt->PosAttrSet();
     179             :     // #i34750# - keep current object rectangle for  drawing
     180             :     // objects. The object rectangle is used on events from the drawing layer
     181             :     // to adjust the positioning attributes - see <SwDrawContact::_Changed(..)>.
     182             :     {
     183           0 :         const SwAnchoredObject* pAnchoredObj = pContact->GetAnchoredObj( &_rSdrObj );
     184           0 :         if ( pAnchoredObj->ISA(SwAnchoredDrawObject) )
     185             :         {
     186             :             const SwAnchoredDrawObject* pAnchoredDrawObj =
     187           0 :                             static_cast<const SwAnchoredDrawObject*>(pAnchoredObj);
     188           0 :             const SwRect aObjRect = _rSdrObj.GetSnapRect();
     189             :             const_cast<SwAnchoredDrawObject*>(pAnchoredDrawObj)
     190           0 :                                         ->SetLastObjRect( aObjRect.SVRect() );
     191             :         }
     192             :     }
     193           0 : }
     194             : 
     195           0 : SwDrawContact* SwDoc::GroupSelection( SdrView& rDrawView )
     196             : {
     197             :     // replace marked 'virtual' drawing objects by the corresponding 'master'
     198             :     // drawing objects.
     199           0 :     SwDrawView::ReplaceMarkedDrawVirtObjs( rDrawView );
     200             : 
     201           0 :     const SdrMarkList &rMrkList = rDrawView.GetMarkedObjectList();
     202           0 :     SwDrawFrmFmt *pFmt = 0L;
     203           0 :     SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
     204           0 :     bool bNoGroup = ( 0 == pObj->GetUpGroup() );
     205           0 :     SwDrawContact* pNewContact = 0;
     206           0 :     if( bNoGroup )
     207             :     {
     208             :         // Revoke anchor attribute.
     209           0 :         SwDrawContact *pMyContact = (SwDrawContact*)GetUserCall(pObj);
     210           0 :         const SwFmtAnchor aAnch( pMyContact->GetFmt()->GetAnchor() );
     211             : 
     212           0 :         SwUndoDrawGroup *const pUndo = (!GetIDocumentUndoRedo().DoesUndo())
     213             :                                  ? 0
     214           0 :                                  : new SwUndoDrawGroup( (sal_uInt16)rMrkList.GetMarkCount() );
     215             : 
     216             :         // #i53320#
     217           0 :         bool bGroupMembersNotPositioned( false );
     218             :         {
     219             :             SwAnchoredDrawObject* pAnchoredDrawObj =
     220           0 :                 static_cast<SwAnchoredDrawObject*>(pMyContact->GetAnchoredObj( pObj ));
     221           0 :             bGroupMembersNotPositioned = pAnchoredDrawObj->NotYetPositioned();
     222             :         }
     223             :         // Destroy ContactObjects and formats.
     224           0 :         for( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
     225             :         {
     226           0 :             pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
     227           0 :             SwDrawContact *pContact = (SwDrawContact*)GetUserCall(pObj);
     228             : 
     229             :             // #i53320#
     230             : #if OSL_DEBUG_LEVEL > 0
     231             :             SwAnchoredDrawObject* pAnchoredDrawObj =
     232             :                 static_cast<SwAnchoredDrawObject*>(pContact->GetAnchoredObj( pObj ));
     233             :             OSL_ENSURE( bGroupMembersNotPositioned == pAnchoredDrawObj->NotYetPositioned(),
     234             :                     "<SwDoc::GroupSelection(..)> - group members have different positioning status!" );
     235             : #endif
     236             : 
     237           0 :             pFmt = (SwDrawFrmFmt*)pContact->GetFmt();
     238             :             // Deletes itself!
     239           0 :             pContact->Changed(*pObj, SDRUSERCALL_DELETE, pObj->GetLastBoundRect() );
     240           0 :             pObj->SetUserCall( 0 );
     241             : 
     242           0 :             if( pUndo )
     243           0 :                 pUndo->AddObj( i, pFmt, pObj );
     244             :             else
     245           0 :                 DelFrmFmt( pFmt );
     246             : 
     247             :             // #i45952# - re-introduce position normalization of group member
     248             :             // objects, because its anchor position is cleared, when they are
     249             :             // grouped.
     250           0 :             Point aAnchorPos( pObj->GetAnchorPos() );
     251           0 :             pObj->NbcSetAnchorPos( Point( 0, 0 ) );
     252           0 :             pObj->NbcMove( Size( aAnchorPos.getX(), aAnchorPos.getY() ) );
     253             :         }
     254             : 
     255             :         pFmt = MakeDrawFrmFmt( OUString("DrawObject"),
     256           0 :                                 GetDfltFrmFmt() );
     257           0 :         pFmt->SetFmtAttr( aAnch );
     258             :         // #i36010# - set layout direction of the position
     259             :         pFmt->SetPositionLayoutDir(
     260           0 :             text::PositionLayoutDir::PositionInLayoutDirOfAnchor );
     261             : 
     262           0 :         rDrawView.GroupMarked();
     263             :         OSL_ENSURE( rMrkList.GetMarkCount() == 1, "GroupMarked more or none groups." );
     264             : 
     265           0 :         SdrObject* pNewGroupObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
     266           0 :         pNewContact = new SwDrawContact( pFmt, pNewGroupObj );
     267             :         // #i35635#
     268           0 :         pNewContact->MoveObjToVisibleLayer( pNewGroupObj );
     269           0 :         pNewContact->ConnectToLayout();
     270             :         // #i53320# - No adjustment of the positioning and alignment
     271             :         // attributes, if group members aren't positioned yet.
     272           0 :         if ( !bGroupMembersNotPositioned )
     273             :         {
     274             :             // #i26791# - Adjust positioning and alignment attributes.
     275           0 :             lcl_AdjustPositioningAttr( pFmt, *pNewGroupObj );
     276             :         }
     277             : 
     278           0 :         if( pUndo )
     279             :         {
     280           0 :             pUndo->SetGroupFmt( pFmt );
     281           0 :             GetIDocumentUndoRedo().AppendUndo( pUndo );
     282           0 :         }
     283             :     }
     284             :     else
     285             :     {
     286           0 :         if (GetIDocumentUndoRedo().DoesUndo())
     287             :         {
     288           0 :             GetIDocumentUndoRedo().ClearRedo();
     289             :         }
     290             : 
     291           0 :         rDrawView.GroupMarked();
     292             :         OSL_ENSURE( rMrkList.GetMarkCount() == 1, "GroupMarked more or none groups." );
     293             :     }
     294             : 
     295           0 :     return pNewContact;
     296             : }
     297             : 
     298           0 : void SwDoc::UnGroupSelection( SdrView& rDrawView )
     299             : {
     300           0 :     bool const bUndo = GetIDocumentUndoRedo().DoesUndo();
     301           0 :     if( bUndo )
     302             :     {
     303           0 :         GetIDocumentUndoRedo().ClearRedo();
     304             :     }
     305             : 
     306             :     // replace marked 'virtual' drawing objects by the corresponding 'master'
     307             :     // drawing objects.
     308           0 :     SwDrawView::ReplaceMarkedDrawVirtObjs( rDrawView );
     309             : 
     310           0 :     const SdrMarkList &rMrkList = rDrawView.GetMarkedObjectList();
     311           0 :     std::vector< std::pair< SwDrawFrmFmt*, SdrObject* > >* pFmtsAndObjs( 0L );
     312           0 :     const size_t nMarkCount( rMrkList.GetMarkCount() );
     313           0 :     if ( nMarkCount )
     314             :     {
     315           0 :         pFmtsAndObjs = new std::vector< std::pair< SwDrawFrmFmt*, SdrObject* > >[nMarkCount];
     316           0 :         SdrObject *pMyObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
     317           0 :         if( !pMyObj->GetUpGroup() )
     318             :         {
     319           0 :             OUString sDrwFmtNm("DrawObject");
     320           0 :             for ( size_t i = 0; i < nMarkCount; ++i )
     321             :             {
     322           0 :                 SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
     323           0 :                 if ( pObj->IsA( TYPE(SdrObjGroup) ) )
     324             :                 {
     325           0 :                     SwDrawContact *pContact = (SwDrawContact*)GetUserCall(pObj);
     326           0 :                     SwFmtAnchor aAnch( pContact->GetFmt()->GetAnchor() );
     327           0 :                     SdrObjList *pLst = ((SdrObjGroup*)pObj)->GetSubList();
     328             : 
     329           0 :                     SwUndoDrawUnGroup* pUndo = 0;
     330           0 :                     if( bUndo )
     331             :                     {
     332           0 :                         pUndo = new SwUndoDrawUnGroup( (SdrObjGroup*)pObj );
     333           0 :                         GetIDocumentUndoRedo().AppendUndo(pUndo);
     334             :                     }
     335             : 
     336           0 :                     for ( size_t i2 = 0; i2 < pLst->GetObjCount(); ++i2 )
     337             :                     {
     338           0 :                         SdrObject* pSubObj = pLst->GetObj( i2 );
     339             :                         SwDrawFrmFmt *pFmt = MakeDrawFrmFmt( sDrwFmtNm,
     340           0 :                                                             GetDfltFrmFmt() );
     341           0 :                         pFmt->SetFmtAttr( aAnch );
     342             :                         // #i36010# - set layout direction of the position
     343             :                         pFmt->SetPositionLayoutDir(
     344           0 :                             text::PositionLayoutDir::PositionInLayoutDirOfAnchor );
     345           0 :                         pFmtsAndObjs[i].push_back( std::pair< SwDrawFrmFmt*, SdrObject* >( pFmt, pSubObj ) );
     346             : 
     347           0 :                         if( bUndo )
     348           0 :                             pUndo->AddObj( static_cast<sal_uInt16>(i2), pFmt );
     349           0 :                     }
     350             :                 }
     351           0 :             }
     352             :         }
     353             :     }
     354           0 :     rDrawView.UnGroupMarked();
     355             :     // creation of <SwDrawContact> instances for the former group members and
     356             :     // its connection to the Writer layout.
     357           0 :     for ( size_t i = 0; i < nMarkCount; ++i )
     358             :     {
     359           0 :         SwUndoDrawUnGroupConnectToLayout* pUndo = 0;
     360           0 :         if( bUndo )
     361             :         {
     362           0 :             pUndo = new SwUndoDrawUnGroupConnectToLayout();
     363           0 :             GetIDocumentUndoRedo().AppendUndo(pUndo);
     364             :         }
     365             : 
     366           0 :         while ( pFmtsAndObjs[i].size() > 0 )
     367             :         {
     368           0 :             SwDrawFrmFmt* pFmt( pFmtsAndObjs[i].back().first );
     369           0 :             SdrObject* pObj( pFmtsAndObjs[i].back().second );
     370           0 :             pFmtsAndObjs[i].pop_back();
     371             : 
     372           0 :             SwDrawContact* pContact = new SwDrawContact( pFmt, pObj );
     373           0 :             pContact->MoveObjToVisibleLayer( pObj );
     374           0 :             pContact->ConnectToLayout();
     375           0 :             lcl_AdjustPositioningAttr( pFmt, *pObj );
     376             : 
     377           0 :             if ( bUndo )
     378             :             {
     379           0 :                 pUndo->AddFmtAndObj( pFmt, pObj );
     380             :             }
     381             :         }
     382             :     }
     383           0 :     delete [] pFmtsAndObjs;
     384           0 : }
     385             : 
     386           2 : bool SwDoc::DeleteSelection( SwDrawView& rDrawView )
     387             : {
     388           2 :     bool bCallBase = false;
     389           2 :     const SdrMarkList &rMrkList = rDrawView.GetMarkedObjectList();
     390           2 :     if( rMrkList.GetMarkCount() )
     391             :     {
     392           2 :         GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL);
     393           2 :         bool bDelMarked = true;
     394             : 
     395           2 :         if( 1 == rMrkList.GetMarkCount() )
     396             :         {
     397           2 :             SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
     398           2 :             if( pObj->ISA(SwVirtFlyDrawObj) )
     399             :             {
     400             :                 SwFlyFrmFmt* pFrmFmt = (SwFlyFrmFmt*)
     401           0 :                     ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm()->GetFmt();
     402           0 :                 if( pFrmFmt )
     403             :                 {
     404           0 :                     getIDocumentLayoutAccess().DelLayoutFmt( pFrmFmt );
     405           0 :                     bDelMarked = false;
     406             :                 }
     407             :             }
     408             :         }
     409             : 
     410           4 :         for( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
     411             :         {
     412           2 :             SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
     413           2 :             if( !pObj->ISA(SwVirtFlyDrawObj) )
     414             :             {
     415           2 :                 SwDrawContact *pC = (SwDrawContact*)GetUserCall(pObj);
     416           2 :                 SwDrawFrmFmt *pFrmFmt = (SwDrawFrmFmt*)pC->GetFmt();
     417           4 :                 if( pFrmFmt &&
     418           2 :                     FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId() )
     419             :                 {
     420           0 :                     rDrawView.MarkObj( pObj, rDrawView.Imp().GetPageView(), true );
     421           0 :                     --i;
     422           0 :                     getIDocumentLayoutAccess().DelLayoutFmt( pFrmFmt );
     423             :                 }
     424             :             }
     425             :         }
     426             : 
     427           2 :         if( rMrkList.GetMarkCount() && bDelMarked )
     428             :         {
     429           2 :             SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
     430           2 :             if( !pObj->GetUpGroup() )
     431             :             {
     432             :                 SwUndoDrawDelete *const pUndo =
     433           2 :                     (!GetIDocumentUndoRedo().DoesUndo())
     434             :                         ? 0
     435           2 :                             : new SwUndoDrawDelete( (sal_uInt16)rMrkList.GetMarkCount() );
     436             : 
     437             :                 // Destroy ContactObjects, save formats.
     438           4 :                 for( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
     439             :                 {
     440           2 :                     const SdrMark& rMark = *rMrkList.GetMark( i );
     441           2 :                     pObj = rMark.GetMarkedSdrObj();
     442           2 :                     SwDrawContact *pContact = (SwDrawContact*)pObj->GetUserCall();
     443           2 :                     if( pContact ) // of course not for grouped objects
     444             :                     {
     445           2 :                         SwDrawFrmFmt *pFmt = (SwDrawFrmFmt*)pContact->GetFmt();
     446             :                         // before delete of selection is performed, marked
     447             :                         // <SwDrawVirtObj>-objects have to be replaced by its
     448             :                         // reference objects.  Thus, assert, if a
     449             :                         // <SwDrawVirt>-object is found in the mark list.
     450           2 :                         if ( pObj->ISA(SwDrawVirtObj) )
     451             :                         {
     452             :                             OSL_FAIL( "<SwDrawVirtObj> is still marked for delete. application will crash!" );
     453             :                         }
     454             :                         // Deletes itself!
     455           2 :                         pContact->Changed(*pObj, SDRUSERCALL_DELETE, pObj->GetLastBoundRect() );
     456           2 :                         pObj->SetUserCall( 0 );
     457             : 
     458           2 :                         if( pUndo )
     459           2 :                             pUndo->AddObj( i, pFmt, rMark );
     460             :                         else
     461           0 :                             DelFrmFmt( pFmt );
     462             :                     }
     463             :                 }
     464             : 
     465           2 :                 if( pUndo )
     466             :                 {
     467           2 :                     GetIDocumentUndoRedo().AppendUndo( pUndo );
     468             :                 }
     469             :             }
     470           2 :             bCallBase = true;
     471             :         }
     472           2 :         getIDocumentState().SetModified();
     473             : 
     474           2 :         GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
     475             :     }
     476             : 
     477           2 :     return bCallBase;
     478             : }
     479             : 
     480         840 : _ZSortFly::_ZSortFly( const SwFrmFmt* pFrmFmt, const SwFmtAnchor* pFlyAn,
     481             :                       sal_uInt32 nArrOrdNum )
     482         840 :     : pFmt( pFrmFmt ), pAnchor( pFlyAn ), nOrdNum( nArrOrdNum )
     483             : {
     484             :     // #i11176#
     485             :     // This also needs to work when no layout exists. Thus, for
     486             :     // FlyFrames an alternative method is used now in that case.
     487         840 :     if( RES_FLYFRMFMT == pFmt->Which() )
     488             :     {
     489         470 :         if( pFmt->getIDocumentLayoutAccess()->GetCurrentViewShell() )
     490             :         {
     491             :             // See if there is an SdrObject for it
     492          44 :             SwFlyFrm* pFly = SwIterator<SwFlyFrm,SwFmt>::FirstElement( *pFrmFmt );
     493          44 :             if( pFly )
     494          44 :                 nOrdNum = pFly->GetVirtDrawObj()->GetOrdNum();
     495             :         }
     496             :         else
     497             :         {
     498             :             // See if there is an SdrObject for it
     499         426 :             SwFlyDrawContact* pContact = SwIterator<SwFlyDrawContact,SwFmt>::FirstElement( *pFrmFmt );
     500         426 :             if( pContact )
     501         426 :                 nOrdNum = pContact->GetMaster()->GetOrdNum();
     502             :         }
     503             :     }
     504         370 :     else if( RES_DRAWFRMFMT == pFmt->Which() )
     505             :     {
     506             :         // See if there is an SdrObject for it
     507         370 :         SwDrawContact* pContact = SwIterator<SwDrawContact,SwFmt>::FirstElement( *pFrmFmt );
     508         370 :         if( pContact )
     509         370 :             nOrdNum = pContact->GetMaster()->GetOrdNum();
     510             :     }
     511             :     else {
     512             :         OSL_ENSURE( false, "what is that for a format?" );
     513             :     }
     514         840 : }
     515             : 
     516             : /// In the Outliner, set a link to the method for field display in edit objects.
     517       10356 : void SwDoc::SetCalcFieldValueHdl(Outliner* pOutliner)
     518             : {
     519       10356 :     pOutliner->SetCalcFieldValueHdl(LINK(this, SwDoc, CalcFieldValueHdl));
     520       10356 : }
     521             : 
     522             : /// Recognise fields/URLs in the Outliner and set how they are displayed.
     523          12 : IMPL_LINK(SwDoc, CalcFieldValueHdl, EditFieldInfo*, pInfo)
     524             : {
     525           6 :     if (pInfo)
     526             :     {
     527           6 :         const SvxFieldItem& rField = pInfo->GetField();
     528           6 :         const SvxFieldData* pField = rField.GetField();
     529             : 
     530           6 :         if (pField && pField->ISA(SvxDateField))
     531             :         {
     532             :             // Date field
     533             :             pInfo->SetRepresentation(
     534             :                 ((const SvxDateField*) pField)->GetFormatted(
     535           0 :                         *GetNumberFormatter( true ), LANGUAGE_SYSTEM) );
     536             :         }
     537           6 :         else if (pField && pField->ISA(SvxURLField))
     538             :         {
     539             :             // URL field
     540           6 :             switch ( ((const SvxURLField*) pField)->GetFormat() )
     541             :             {
     542             :                 case SVXURLFORMAT_APPDEFAULT: //!!! Can be set in App???
     543             :                 case SVXURLFORMAT_REPR:
     544             :                 {
     545             :                     pInfo->SetRepresentation(
     546           6 :                         ((const SvxURLField*)pField)->GetRepresentation());
     547             :                 }
     548           6 :                 break;
     549             : 
     550             :                 case SVXURLFORMAT_URL:
     551             :                 {
     552             :                     pInfo->SetRepresentation(
     553           0 :                         ((const SvxURLField*)pField)->GetURL());
     554             :                 }
     555           0 :                 break;
     556             :             }
     557             : 
     558             :             sal_uInt16 nChrFmt;
     559             : 
     560           6 :             if (IsVisitedURL(((const SvxURLField*)pField)->GetURL()))
     561           0 :                 nChrFmt = RES_POOLCHR_INET_VISIT;
     562             :             else
     563           6 :                 nChrFmt = RES_POOLCHR_INET_NORMAL;
     564             : 
     565           6 :             SwFmt *pFmt = getIDocumentStylePoolAccess().GetCharFmtFromPool(nChrFmt);
     566             : 
     567           6 :             Color aColor(COL_LIGHTBLUE);
     568           6 :             if (pFmt)
     569           6 :                 aColor = pFmt->GetColor().GetValue();
     570             : 
     571           6 :             pInfo->SetTxtColor(aColor);
     572             :         }
     573           0 :         else if (pField && pField->ISA(SdrMeasureField))
     574             :         {
     575             :             // Measure field
     576           0 :             pInfo->ClearFldColor();
     577             :         }
     578           0 :         else if ( pField && pField->ISA(SvxExtTimeField))
     579             :         {
     580             :             // Time field
     581             :             pInfo->SetRepresentation(
     582             :                 ((const SvxExtTimeField*) pField)->GetFormatted(
     583           0 :                         *GetNumberFormatter( true ), LANGUAGE_SYSTEM) );
     584             :         }
     585             :         else
     586             :         {
     587             :             OSL_FAIL("unknown field command");
     588           0 :             pInfo->SetRepresentation( OUString( '?' ) );
     589             :         }
     590             :     }
     591             : 
     592           6 :     return(0);
     593             : }
     594             : 
     595             : // #i62875#
     596             : namespace docfunc
     597             : {
     598           2 :     bool ExistsDrawObjs( SwDoc& p_rDoc )
     599             :     {
     600           2 :         bool bExistsDrawObjs( false );
     601             : 
     602           4 :         if ( p_rDoc.getIDocumentDrawModelAccess().GetDrawModel() &&
     603           2 :              p_rDoc.getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 ) )
     604             :         {
     605           2 :             const SdrPage& rSdrPage( *(p_rDoc.getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 )) );
     606             : 
     607           2 :             SdrObjListIter aIter( rSdrPage, IM_FLAT );
     608           4 :             while( aIter.IsMore() )
     609             :             {
     610           0 :                 SdrObject* pObj( aIter.Next() );
     611           0 :                 if ( !dynamic_cast<SwVirtFlyDrawObj*>(pObj) &&
     612           0 :                      !dynamic_cast<SwFlyDrawObj*>(pObj) )
     613             :                 {
     614           0 :                     bExistsDrawObjs = true;
     615           0 :                     break;
     616             :                 }
     617           2 :             }
     618             :         }
     619             : 
     620           2 :         return bExistsDrawObjs;
     621             :     }
     622             : 
     623           0 :     bool AllDrawObjsOnPage( SwDoc& p_rDoc )
     624             :     {
     625           0 :         bool bAllDrawObjsOnPage( true );
     626             : 
     627           0 :         if ( p_rDoc.getIDocumentDrawModelAccess().GetDrawModel() &&
     628           0 :              p_rDoc.getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 ) )
     629             :         {
     630           0 :             const SdrPage& rSdrPage( *(p_rDoc.getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 )) );
     631             : 
     632           0 :             SdrObjListIter aIter( rSdrPage, IM_FLAT );
     633           0 :             while( aIter.IsMore() )
     634             :             {
     635           0 :                 SdrObject* pObj( aIter.Next() );
     636           0 :                 if ( !dynamic_cast<SwVirtFlyDrawObj*>(pObj) &&
     637           0 :                      !dynamic_cast<SwFlyDrawObj*>(pObj) )
     638             :                 {
     639             :                     SwDrawContact* pDrawContact =
     640           0 :                             dynamic_cast<SwDrawContact*>(::GetUserCall( pObj ));
     641           0 :                     if ( pDrawContact )
     642             :                     {
     643             :                         SwAnchoredDrawObject* pAnchoredDrawObj =
     644           0 :                             dynamic_cast<SwAnchoredDrawObject*>(pDrawContact->GetAnchoredObj( pObj ));
     645             : 
     646             :                         // error handling
     647             :                         {
     648           0 :                             if ( !pAnchoredDrawObj )
     649             :                             {
     650             :                                 OSL_FAIL( "<docfunc::AllDrawObjsOnPage() - missing anchored draw object" );
     651           0 :                                 bAllDrawObjsOnPage = false;
     652           0 :                                 break;
     653             :                             }
     654             :                         }
     655             : 
     656           0 :                         if ( pAnchoredDrawObj->NotYetPositioned() )
     657             :                         {
     658             :                             // The drawing object isn't yet layouted.
     659             :                             // Thus, it isn't known, if all drawing objects are on page.
     660           0 :                             bAllDrawObjsOnPage = false;
     661           0 :                             break;
     662             :                         }
     663           0 :                         else if ( pAnchoredDrawObj->IsOutsidePage() )
     664             :                         {
     665           0 :                             bAllDrawObjsOnPage = false;
     666           0 :                             break;
     667             :                         }
     668             :                     }
     669             :                     else
     670             :                     {
     671             :                         // contact object of drawing object doesn't exists.
     672             :                         // Thus, the drawing object isn't yet positioned.
     673             :                         // Thus, it isn't known, if all drawing objects are on page.
     674           0 :                         bAllDrawObjsOnPage = false;
     675           0 :                         break;
     676             :                     }
     677             :                 }
     678           0 :             }
     679             :         }
     680             : 
     681           0 :         return bAllDrawObjsOnPage;
     682             :     }
     683         270 : }
     684             : 
     685             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10