LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/draw - dpage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 19 95 20.0 %
Date: 2012-12-17 Functions: 5 8 62.5 %
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         530 : SwDPage::SwDPage(SwDrawDocument& rNewModel, sal_Bool bMasterPage) :
      52             :     FmFormPage(rNewModel, 0, bMasterPage),
      53             :     pGridLst( 0 ),
      54         530 :     rDoc(rNewModel.GetDoc())
      55             : {
      56         530 : }
      57             : 
      58             : 
      59         366 : SwDPage::~SwDPage()
      60             : {
      61         122 :     delete pGridLst;
      62         244 : }
      63             : 
      64             : /*************************************************************************
      65             : |*
      66             : |*  SwDPage::ReplaceObject()
      67             : |*
      68             : *************************************************************************/
      69             : 
      70          74 : SdrObject*  SwDPage::ReplaceObject( SdrObject* pNewObj, sal_uLong nObjNum )
      71             : {
      72          74 :     SdrObject *pOld = GetObj( nObjNum );
      73             :     OSL_ENSURE( pOld, "Oups, Object not replaced" );
      74             :     SdrObjUserCall* pContact;
      75         148 :     if ( 0 != ( pContact = GetUserCall(pOld) ) &&
      76          74 :          RES_DRAWFRMFMT == ((SwContact*)pContact)->GetFmt()->Which())
      77           0 :         ((SwDrawContact*)pContact)->ChangeMasterObject( pNewObj );
      78          74 :     return FmFormPage::ReplaceObject( pNewObj, nObjNum );
      79             : }
      80             : 
      81             : /*************************************************************************
      82             : |*
      83             : |*  SwDPage::GetGridFrameList()
      84             : |*
      85             : *************************************************************************/
      86             : 
      87           0 : void InsertGridFrame( SdrPageGridFrameList *pLst, const SwFrm *pPg )
      88             : {
      89           0 :     SwRect aPrt( pPg->Prt() );
      90           0 :     aPrt += pPg->Frm().Pos();
      91           0 :     const Rectangle aUser( aPrt.SVRect() );
      92           0 :     const Rectangle aPaper( pPg->Frm().SVRect() );
      93           0 :     pLst->Insert( SdrPageGridFrame( aPaper, aUser ) );
      94           0 : }
      95             : 
      96             : 
      97           0 : const SdrPageGridFrameList*  SwDPage::GetGridFrameList(
      98             :                         const SdrPageView* pPV, const Rectangle *pRect ) const
      99             : {
     100           0 :     ViewShell *pSh = ((SwDrawDocument*)GetModel())->GetDoc().GetCurrentViewShell(); //swmod 071108//swmod 071225
     101           0 :     if ( pSh )
     102             :     {
     103           0 :         while ( pSh->Imp()->GetPageView() != pPV )
     104           0 :             pSh = (ViewShell*)pSh->GetNext();
     105           0 :         if ( pSh )
     106             :         {
     107           0 :             if ( pGridLst )
     108           0 :                 ((SwDPage*)this)->pGridLst->Clear();
     109             :             else
     110           0 :                 ((SwDPage*)this)->pGridLst = new SdrPageGridFrameList;
     111             : 
     112           0 :             if ( pRect )
     113             :             {
     114             :                 //Das Drawing verlang alle Seiten, die mit dem Rect ueberlappen.
     115           0 :                 const SwRect aRect( *pRect );
     116           0 :                 const SwFrm *pPg = pSh->GetLayout()->Lower();
     117           0 :                 do
     118           0 :                 {   if ( pPg->Frm().IsOver( aRect ) )
     119           0 :                         ::InsertGridFrame( ((SwDPage*)this)->pGridLst, pPg );
     120           0 :                     pPg = pPg->GetNext();
     121             :                 } while ( pPg );
     122             :             }
     123             :             else
     124             :             {
     125             :                 //Das Drawing verlangt alle sichbaren Seiten
     126           0 :                 const SwFrm *pPg = pSh->Imp()->GetFirstVisPage();
     127           0 :                 if ( pPg )
     128           0 :                     do
     129           0 :                     {   ::InsertGridFrame( ((SwDPage*)this)->pGridLst, pPg );
     130           0 :                         pPg = pPg->GetNext();
     131           0 :                     } while ( pPg && pPg->Frm().IsOver( pSh->VisArea() ) );
     132             :             }
     133             :         }
     134             :     }
     135           0 :     return pGridLst;
     136             : }
     137             : 
     138           0 : sal_Bool SwDPage::RequestHelp( Window* pWindow, SdrView* pView,
     139             :                            const HelpEvent& rEvt )
     140             : {
     141           0 :     sal_Bool bWeiter = sal_True;
     142             : 
     143           0 :     if( rEvt.GetMode() & ( HELPMODE_QUICK | HELPMODE_BALLOON ))
     144             :     {
     145           0 :         Point aPos( rEvt.GetMousePosPixel() );
     146           0 :         aPos = pWindow->ScreenToOutputPixel( aPos );
     147           0 :         aPos = pWindow->PixelToLogic( aPos );
     148             : 
     149             :         SdrPageView* pPV;
     150             :         SdrObject* pObj;
     151           0 :         if( pView->PickObj( aPos, 0, pObj, pPV, SDRSEARCH_PICKMACRO ) &&
     152           0 :              pObj->ISA(SwVirtFlyDrawObj) )
     153             :         {
     154           0 :             SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
     155           0 :             const SwFmtURL &rURL = pFly->GetFmt()->GetURL();
     156           0 :             String sTxt;
     157           0 :             if( rURL.GetMap() )
     158             :             {
     159           0 :                 IMapObject *pTmpObj = pFly->GetFmt()->GetIMapObject( aPos, pFly );
     160           0 :                 if( pTmpObj )
     161             :                 {
     162           0 :                     sTxt = pTmpObj->GetAltText();
     163           0 :                     if ( !sTxt.Len() )
     164           0 :                         sTxt = URIHelper::removePassword( pTmpObj->GetURL(),
     165             :                                         INetURLObject::WAS_ENCODED,
     166           0 :                                            INetURLObject::DECODE_UNAMBIGUOUS);
     167             :                 }
     168             :             }
     169           0 :             else if ( rURL.GetURL().Len() )
     170             :             {
     171           0 :                 sTxt = URIHelper::removePassword( rURL.GetURL(),
     172             :                                         INetURLObject::WAS_ENCODED,
     173           0 :                                            INetURLObject::DECODE_UNAMBIGUOUS);
     174             : 
     175           0 :                 if( rURL.IsServerMap() )
     176             :                 {
     177             :                     // dann die rel. Pixel Position anhaengen !!
     178           0 :                     Point aPt( aPos );
     179           0 :                     aPt -= pFly->Frm().Pos();
     180             :                     // ohne MapMode-Offset !!!!!
     181             :                     // ohne MapMode-Offset, ohne Offset, o ... !!!!!
     182             :                     aPt = pWindow->LogicToPixel(
     183           0 :                             aPt, MapMode( MAP_TWIP ) );
     184           0 :                     ((( sTxt += '?' ) += String::CreateFromInt32( aPt.X() ))
     185           0 :                              += ',' ) += String::CreateFromInt32( aPt.Y() );
     186             :                 }
     187             :             }
     188             : 
     189           0 :             if ( sTxt.Len() )
     190             :             {
     191             :                 // #i80029#
     192           0 :                 sal_Bool bExecHyperlinks = rDoc.GetDocShell()->IsReadOnly();
     193           0 :                 if ( !bExecHyperlinks )
     194             :                 {
     195           0 :                     SvtSecurityOptions aSecOpts;
     196           0 :                     bExecHyperlinks = !aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK );
     197             : 
     198           0 :                     if ( !bExecHyperlinks )
     199             :                     {
     200           0 :                         sTxt.InsertAscii( ": ", 0 );
     201           0 :                         sTxt.Insert( ViewShell::GetShellRes()->aHyperlinkClick, 0 );
     202           0 :                     }
     203             :                 }
     204             : 
     205             : 
     206           0 :                 if( rEvt.GetMode() & HELPMODE_BALLOON )
     207             :                 {
     208           0 :                     Help::ShowBalloon( pWindow, rEvt.GetMousePosPixel(), sTxt );
     209             :                 }
     210             :                 else
     211             :                 {
     212             :             // dann zeige die Hilfe mal an:
     213           0 :                     Rectangle aRect( rEvt.GetMousePosPixel(), Size(1,1) );
     214           0 :                     Help::ShowQuickHelp( pWindow, aRect, sTxt );
     215             :                 }
     216           0 :                 bWeiter = sal_False;
     217           0 :             }
     218             :         }
     219             :     }
     220             : 
     221           0 :     if( bWeiter )
     222           0 :         bWeiter = !FmFormPage::RequestHelp( pWindow, pView, rEvt );
     223             : 
     224           0 :     return bWeiter;
     225             : }
     226             : 
     227         394 : Reference< XInterface > SwDPage::createUnoPage()
     228             : {
     229         394 :     Reference < XInterface > xRet;
     230         394 :     SwDocShell* pDocShell = rDoc.GetDocShell();
     231         394 :     if ( pDocShell )
     232             :     {
     233         394 :         Reference<XModel> xModel = pDocShell->GetBaseModel();
     234         394 :         Reference<XDrawPageSupplier> xPageSupp(xModel, UNO_QUERY);
     235         394 :         xRet = xPageSupp->getDrawPage();
     236             :     }
     237         394 :     return xRet;
     238             : }
     239             : 
     240             : 
     241             : 
     242             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10