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

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <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           0 : SwDPage::SwDPage(SwDrawDocument& rNewModel, sal_Bool bMasterPage) :
      52             :     FmFormPage(rNewModel, bMasterPage),
      53             :     pGridLst( 0 ),
      54           0 :     rDoc(rNewModel.GetDoc())
      55             : {
      56           0 : }
      57             : 
      58           0 : SwDPage::~SwDPage()
      59             : {
      60           0 :     delete pGridLst;
      61           0 : }
      62             : 
      63           0 : SdrObject*  SwDPage::ReplaceObject( SdrObject* pNewObj, sal_uLong nObjNum )
      64             : {
      65           0 :     SdrObject *pOld = GetObj( nObjNum );
      66             :     OSL_ENSURE( pOld, "Oups, Object not replaced" );
      67             :     SdrObjUserCall* pContact;
      68           0 :     if ( 0 != ( pContact = GetUserCall(pOld) ) &&
      69           0 :          RES_DRAWFRMFMT == ((SwContact*)pContact)->GetFmt()->Which())
      70           0 :         ((SwDrawContact*)pContact)->ChangeMasterObject( pNewObj );
      71           0 :     return FmFormPage::ReplaceObject( pNewObj, nObjNum );
      72             : }
      73             : 
      74           0 : void InsertGridFrame( SdrPageGridFrameList *pLst, const SwFrm *pPg )
      75             : {
      76           0 :     SwRect aPrt( pPg->Prt() );
      77           0 :     aPrt += pPg->Frm().Pos();
      78           0 :     const Rectangle aUser( aPrt.SVRect() );
      79           0 :     const Rectangle aPaper( pPg->Frm().SVRect() );
      80           0 :     pLst->Insert( SdrPageGridFrame( aPaper, aUser ) );
      81           0 : }
      82             : 
      83           0 : const SdrPageGridFrameList*  SwDPage::GetGridFrameList(
      84             :                         const SdrPageView* pPV, const Rectangle *pRect ) const
      85             : {
      86           0 :     SwViewShell *pSh = ((SwDrawDocument*)GetModel())->GetDoc().GetCurrentViewShell();
      87           0 :     if ( pSh )
      88             :     {
      89           0 :         while ( pSh->Imp()->GetPageView() != pPV )
      90           0 :             pSh = (SwViewShell*)pSh->GetNext();
      91           0 :         if ( pSh )
      92             :         {
      93           0 :             if ( pGridLst )
      94           0 :                 ((SwDPage*)this)->pGridLst->Clear();
      95             :             else
      96           0 :                 ((SwDPage*)this)->pGridLst = new SdrPageGridFrameList;
      97             : 
      98           0 :             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           0 :                 const SwFrm *pPg = pSh->Imp()->GetFirstVisPage();
     113           0 :                 if ( pPg )
     114           0 :                     do
     115           0 :                     {   ::InsertGridFrame( ((SwDPage*)this)->pGridLst, pPg );
     116           0 :                         pPg = pPg->GetNext();
     117           0 :                     } while ( pPg && pPg->Frm().IsOver( pSh->VisArea() ) );
     118             :             }
     119             :         }
     120             :     }
     121           0 :     return pGridLst;
     122             : }
     123             : 
     124           0 : sal_Bool SwDPage::RequestHelp( Window* pWindow, SdrView* pView,
     125             :                            const HelpEvent& rEvt )
     126             : {
     127           0 :     sal_Bool bContinue = 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 :             OUString 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.isEmpty() )
     150           0 :                         sTxt = URIHelper::removePassword( pTmpObj->GetURL(),
     151             :                                         INetURLObject::WAS_ENCODED,
     152           0 :                                            INetURLObject::DECODE_UNAMBIGUOUS);
     153             :                 }
     154             :             }
     155           0 :             else if ( !rURL.GetURL().isEmpty() )
     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.isEmpty() )
     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           0 :                         sTxt = SwViewShell::GetShellRes()->aLinkCtrlClick + ": " + sTxt;
     186             :                     else
     187           0 :                         sTxt = SwViewShell::GetShellRes()->aLinkClick + ": " + sTxt;
     188             :                 }
     189             : 
     190           0 :                 if( rEvt.GetMode() & HELPMODE_BALLOON )
     191             :                 {
     192           0 :                     Help::ShowBalloon( pWindow, rEvt.GetMousePosPixel(), sTxt );
     193             :                 }
     194             :                 else
     195             :                 {
     196             :                     // then display the help:
     197           0 :                     Rectangle aRect( rEvt.GetMousePosPixel(), Size(1,1) );
     198           0 :                     Help::ShowQuickHelp( pWindow, aRect, sTxt );
     199             :                 }
     200           0 :                 bContinue = sal_False;
     201           0 :             }
     202             :         }
     203             :     }
     204             : 
     205           0 :     if( bContinue )
     206           0 :         bContinue = !FmFormPage::RequestHelp( pWindow, pView, rEvt );
     207             : 
     208           0 :     return bContinue;
     209             : }
     210             : 
     211           0 : Reference< XInterface > SwDPage::createUnoPage()
     212             : {
     213           0 :     Reference < XInterface > xRet;
     214           0 :     SwDocShell* pDocShell = rDoc.GetDocShell();
     215           0 :     if ( pDocShell )
     216             :     {
     217           0 :         Reference<XModel> xModel = pDocShell->GetBaseModel();
     218           0 :         Reference<XDrawPageSupplier> xPageSupp(xModel, UNO_QUERY);
     219           0 :         xRet = xPageSupp->getDrawPage();
     220             :     }
     221           0 :     return xRet;
     222             : }
     223             : 
     224             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10