LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/core/draw - dpage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 43 96 44.8 %
Date: 2013-07-09 Functions: 9 10 90.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <basic/basmgr.hxx>
      21             : #include <svtools/imapobj.hxx>
      22             : #include <svl/urihelper.hxx>
      23             : #include <unotools/securityoptions.hxx>
      24             : #include <vcl/help.hxx>
      25             : #include <svx/svdview.hxx>
      26             : #include <fmturl.hxx>
      27             : #include <frmfmt.hxx>
      28             : #include <doc.hxx>
      29             : #include <shellres.hxx>
      30             : #include <viewimp.hxx>
      31             : #include <pagefrm.hxx>
      32             : #include <cntfrm.hxx>
      33             : #include <rootfrm.hxx>
      34             : #include <frmatr.hxx>
      35             : #include <viewsh.hxx>
      36             : #include <drawdoc.hxx>
      37             : #include <dpage.hxx>
      38             : #include <dcontact.hxx>
      39             : #include <dflyobj.hxx>
      40             : #include <docsh.hxx>
      41             : #include <usrfld.hxx>
      42             : #include <flyfrm.hxx>
      43             : #include <ndnotxt.hxx>
      44             : #include <grfatr.hxx>
      45             : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
      46             : 
      47             : using namespace ::com::sun::star::uno;
      48             : using namespace ::com::sun::star::drawing;
      49             : using namespace ::com::sun::star::frame;
      50             : 
      51         823 : SwDPage::SwDPage(SwDrawDocument& rNewModel, sal_Bool bMasterPage) :
      52             :     FmFormPage(rNewModel, 0, bMasterPage),
      53             :     pGridLst( 0 ),
      54         823 :     rDoc(rNewModel.GetDoc())
      55             : {
      56         823 : }
      57             : 
      58        2463 : SwDPage::~SwDPage()
      59             : {
      60         821 :     delete pGridLst;
      61        1642 : }
      62             : 
      63          95 : SdrObject*  SwDPage::ReplaceObject( SdrObject* pNewObj, sal_uLong nObjNum )
      64             : {
      65          95 :     SdrObject *pOld = GetObj( nObjNum );
      66             :     OSL_ENSURE( pOld, "Oups, Object not replaced" );
      67             :     SdrObjUserCall* pContact;
      68         190 :     if ( 0 != ( pContact = GetUserCall(pOld) ) &&
      69          95 :          RES_DRAWFRMFMT == ((SwContact*)pContact)->GetFmt()->Which())
      70           0 :         ((SwDrawContact*)pContact)->ChangeMasterObject( pNewObj );
      71          95 :     return FmFormPage::ReplaceObject( pNewObj, nObjNum );
      72             : }
      73             : 
      74          13 : void InsertGridFrame( SdrPageGridFrameList *pLst, const SwFrm *pPg )
      75             : {
      76          13 :     SwRect aPrt( pPg->Prt() );
      77          13 :     aPrt += pPg->Frm().Pos();
      78          13 :     const Rectangle aUser( aPrt.SVRect() );
      79          13 :     const Rectangle aPaper( pPg->Frm().SVRect() );
      80          13 :     pLst->Insert( SdrPageGridFrame( aPaper, aUser ) );
      81          13 : }
      82             : 
      83          13 : const SdrPageGridFrameList*  SwDPage::GetGridFrameList(
      84             :                         const SdrPageView* pPV, const Rectangle *pRect ) const
      85             : {
      86          13 :     ViewShell *pSh = ((SwDrawDocument*)GetModel())->GetDoc().GetCurrentViewShell(); //swmod 071108//swmod 071225
      87          13 :     if ( pSh )
      88             :     {
      89          26 :         while ( pSh->Imp()->GetPageView() != pPV )
      90           0 :             pSh = (ViewShell*)pSh->GetNext();
      91          13 :         if ( pSh )
      92             :         {
      93          13 :             if ( pGridLst )
      94          12 :                 ((SwDPage*)this)->pGridLst->Clear();
      95             :             else
      96           1 :                 ((SwDPage*)this)->pGridLst = new SdrPageGridFrameList;
      97             : 
      98          13 :             if ( pRect )
      99             :             {
     100             :                 //The drawing demands all pages which overlap with the rest.
     101           0 :                 const SwRect aRect( *pRect );
     102           0 :                 const SwFrm *pPg = pSh->GetLayout()->Lower();
     103           0 :                 do
     104           0 :                 {   if ( pPg->Frm().IsOver( aRect ) )
     105           0 :                         ::InsertGridFrame( ((SwDPage*)this)->pGridLst, pPg );
     106           0 :                     pPg = pPg->GetNext();
     107             :                 } while ( pPg );
     108             :             }
     109             :             else
     110             :             {
     111             :                 //The drawing demands all visible pages
     112          13 :                 const SwFrm *pPg = pSh->Imp()->GetFirstVisPage();
     113          13 :                 if ( pPg )
     114          13 :                     do
     115          13 :                     {   ::InsertGridFrame( ((SwDPage*)this)->pGridLst, pPg );
     116          13 :                         pPg = pPg->GetNext();
     117          13 :                     } while ( pPg && pPg->Frm().IsOver( pSh->VisArea() ) );
     118             :             }
     119             :         }
     120             :     }
     121          13 :     return pGridLst;
     122             : }
     123             : 
     124           0 : sal_Bool SwDPage::RequestHelp( Window* pWindow, SdrView* pView,
     125             :                            const HelpEvent& rEvt )
     126             : {
     127           0 :     sal_Bool bWeiter = sal_True;
     128             : 
     129           0 :     if( rEvt.GetMode() & ( HELPMODE_QUICK | HELPMODE_BALLOON ))
     130             :     {
     131           0 :         Point aPos( rEvt.GetMousePosPixel() );
     132           0 :         aPos = pWindow->ScreenToOutputPixel( aPos );
     133           0 :         aPos = pWindow->PixelToLogic( aPos );
     134             : 
     135             :         SdrPageView* pPV;
     136             :         SdrObject* pObj;
     137           0 :         if( pView->PickObj( aPos, 0, pObj, pPV, SDRSEARCH_PICKMACRO ) &&
     138           0 :              pObj->ISA(SwVirtFlyDrawObj) )
     139             :         {
     140           0 :             SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
     141           0 :             const SwFmtURL &rURL = pFly->GetFmt()->GetURL();
     142           0 :             String sTxt;
     143           0 :             if( rURL.GetMap() )
     144             :             {
     145           0 :                 IMapObject *pTmpObj = pFly->GetFmt()->GetIMapObject( aPos, pFly );
     146           0 :                 if( pTmpObj )
     147             :                 {
     148           0 :                     sTxt = pTmpObj->GetAltText();
     149           0 :                     if ( !sTxt.Len() )
     150           0 :                         sTxt = URIHelper::removePassword( pTmpObj->GetURL(),
     151             :                                         INetURLObject::WAS_ENCODED,
     152           0 :                                            INetURLObject::DECODE_UNAMBIGUOUS);
     153             :                 }
     154             :             }
     155           0 :             else if ( rURL.GetURL().Len() )
     156             :             {
     157           0 :                 sTxt = URIHelper::removePassword( rURL.GetURL(),
     158             :                                         INetURLObject::WAS_ENCODED,
     159           0 :                                            INetURLObject::DECODE_UNAMBIGUOUS);
     160             : 
     161           0 :                 if( rURL.IsServerMap() )
     162             :                 {
     163             :                     // then append the relative pixel position!!
     164           0 :                     Point aPt( aPos );
     165           0 :                     aPt -= pFly->Frm().Pos();
     166             :                     // without MapMode-Offset !!!!!
     167             :                     // without MapMode-Offset, without Offset, w ... !!!!!
     168             :                     aPt = pWindow->LogicToPixel(
     169           0 :                             aPt, MapMode( MAP_TWIP ) );
     170           0 :                     ((( sTxt += '?' ) += OUString::number( aPt.getX() ))
     171           0 :                              += ',' ) += OUString::number( aPt.getY() );
     172             :                 }
     173             :             }
     174             : 
     175           0 :             if ( sTxt.Len() )
     176             :             {
     177             :                 // #i80029#
     178           0 :                 sal_Bool bExecHyperlinks = rDoc.GetDocShell()->IsReadOnly();
     179           0 :                 if ( !bExecHyperlinks )
     180             :                 {
     181           0 :                     SvtSecurityOptions aSecOpts;
     182           0 :                     bExecHyperlinks = !aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
     183             : 
     184           0 :                     if ( !bExecHyperlinks )
     185             :                     {
     186           0 :                         sTxt.InsertAscii( ": ", 0 );
     187           0 :                         sTxt.Insert( ViewShell::GetShellRes()->aHyperlinkClick, 0 );
     188           0 :                     }
     189             :                 }
     190             : 
     191             : 
     192           0 :                 if( rEvt.GetMode() & HELPMODE_BALLOON )
     193             :                 {
     194           0 :                     Help::ShowBalloon( pWindow, rEvt.GetMousePosPixel(), sTxt );
     195             :                 }
     196             :                 else
     197             :                 {
     198             :                     // then display the help:
     199           0 :                     Rectangle aRect( rEvt.GetMousePosPixel(), Size(1,1) );
     200           0 :                     Help::ShowQuickHelp( pWindow, aRect, sTxt );
     201             :                 }
     202           0 :                 bWeiter = sal_False;
     203           0 :             }
     204             :         }
     205             :     }
     206             : 
     207           0 :     if( bWeiter )
     208           0 :         bWeiter = !FmFormPage::RequestHelp( pWindow, pView, rEvt );
     209             : 
     210           0 :     return bWeiter;
     211             : }
     212             : 
     213         526 : Reference< XInterface > SwDPage::createUnoPage()
     214             : {
     215         526 :     Reference < XInterface > xRet;
     216         526 :     SwDocShell* pDocShell = rDoc.GetDocShell();
     217         526 :     if ( pDocShell )
     218             :     {
     219         526 :         Reference<XModel> xModel = pDocShell->GetBaseModel();
     220        1052 :         Reference<XDrawPageSupplier> xPageSupp(xModel, UNO_QUERY);
     221        1052 :         xRet = xPageSupp->getDrawPage();
     222             :     }
     223         526 :     return xRet;
     224          99 : }
     225             : 
     226             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10