LCOV - code coverage report
Current view: top level - sw/source/core/doc - visiturl.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 54 0.0 %
Date: 2014-04-14 Functions: 0 5 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 <sfx2/docfile.hxx>
      21             : #include <svl/inethist.hxx>
      22             : #include <fmtinfmt.hxx>
      23             : #include <txtinet.hxx>
      24             : #include <doc.hxx>
      25             : #include <visiturl.hxx>
      26             : #include <hints.hxx>
      27             : #include <ndtxt.hxx>
      28             : #include <editsh.hxx>
      29             : #include <docsh.hxx>
      30             : 
      31           0 : SwURLStateChanged::SwURLStateChanged( const SwDoc* pD )
      32           0 :     : pDoc( pD )
      33             : {
      34           0 :     StartListening( *INetURLHistory::GetOrCreate() );
      35           0 : }
      36             : 
      37           0 : SwURLStateChanged::~SwURLStateChanged()
      38             : {
      39           0 :     EndListening( *INetURLHistory::GetOrCreate() );
      40           0 : }
      41             : 
      42           0 : void SwURLStateChanged::Notify( SfxBroadcaster& , const SfxHint& rHint )
      43             : {
      44           0 :     if( rHint.ISA( INetURLHistoryHint ) && pDoc->GetCurrentViewShell() )
      45             :     {
      46             :         // This URL has been changed:
      47           0 :         const INetURLObject* pIURL = ((INetURLHistoryHint&)rHint).GetObject();
      48           0 :         OUString sURL( pIURL->GetMainURL( INetURLObject::NO_DECODE ) ), sBkmk;
      49             : 
      50           0 :         SwEditShell* pESh = pDoc->GetEditShell();
      51             : 
      52           0 :         if( pDoc->GetDocShell() && pDoc->GetDocShell()->GetMedium() &&
      53             :             // If this is our Doc, we can also have local jumps!
      54           0 :             pDoc->GetDocShell()->GetMedium()->GetName().equals(sURL) )
      55           0 :             sBkmk = "#" + pIURL->GetMark();
      56             : 
      57           0 :         bool bAction = false, bUnLockView = false;
      58           0 :         sal_uInt32 nMaxItems = pDoc->GetAttrPool().GetItemCount2( RES_TXTATR_INETFMT );
      59           0 :         for( sal_uInt32 n = 0; n < nMaxItems; ++n )
      60             :         {
      61           0 :             const SwFmtINetFmt* pItem = (SwFmtINetFmt*)pDoc->GetAttrPool().GetItem2(RES_TXTATR_INETFMT, n );
      62           0 :             if( pItem != 0 &&
      63           0 :                 ( pItem->GetValue() == sURL || ( !sBkmk.isEmpty() && pItem->GetValue() == sBkmk )))
      64             :             {
      65           0 :                 const SwTxtINetFmt* pTxtAttr = pItem->GetTxtINetFmt();
      66           0 :                 if (pTxtAttr != 0)
      67             :                 {
      68           0 :                     const SwTxtNode* pTxtNd = pTxtAttr->GetpTxtNode();
      69           0 :                     if (pTxtNd != 0)
      70             :                     {
      71           0 :                         if( !bAction && pESh )
      72             :                         {
      73           0 :                             pESh->StartAllAction();
      74           0 :                             bAction = true;
      75           0 :                             bUnLockView = !pESh->IsViewLocked();
      76           0 :                             pESh->LockView( sal_True );
      77             :                         }
      78           0 :                         const_cast<SwTxtINetFmt*>(pTxtAttr)->SetVisitedValid( false );
      79           0 :                         const SwTxtAttr* pAttr = pTxtAttr;
      80           0 :                         SwUpdateAttr aUpdateAttr( *pAttr->GetStart(),
      81           0 :                                                   *pAttr->End(),
      82           0 :                                                   RES_FMT_CHG );
      83           0 :                         ((SwTxtNode*)pTxtNd)->ModifyNotification( &aUpdateAttr, &aUpdateAttr );
      84             :                     }
      85             :                 }
      86             :             }
      87             :         }
      88             : 
      89           0 :         if( bAction )
      90           0 :             pESh->EndAllAction();
      91           0 :         if( bUnLockView )
      92           0 :             pESh->LockView( sal_False );
      93             :     }
      94           0 : }
      95             : 
      96             : // Check if the URL has been visited before. Via the Doc, if only one Bookmark is set
      97             : // We need to put the Doc's name before it!
      98           0 : bool SwDoc::IsVisitedURL( const OUString& rURL ) const
      99             : {
     100           0 :     bool bRet = false;
     101           0 :     if( !rURL.isEmpty() )
     102             :     {
     103           0 :         INetURLHistory *pHist = INetURLHistory::GetOrCreate();
     104           0 :         if( '#' == rURL[0] && mpDocShell && mpDocShell->GetMedium() )
     105             :         {
     106           0 :             INetURLObject aIObj( mpDocShell->GetMedium()->GetURLObject() );
     107           0 :             aIObj.SetMark( rURL.copy( 1 ) );
     108           0 :             bRet = pHist->QueryUrl( aIObj );
     109             :         }
     110             :         else
     111           0 :             bRet = pHist->QueryUrl( rURL );
     112             : 
     113             :         // We also want to be informed about status updates in the History
     114           0 :         if( !mpURLStateChgd )
     115             :         {
     116           0 :             SwDoc* pD = (SwDoc*)this;
     117           0 :             pD->mpURLStateChgd = new SwURLStateChanged( this );
     118             :         }
     119             :     }
     120           0 :     return bRet;
     121             : }
     122             : 
     123             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10