LCOV - code coverage report
Current view: top level - sw/source/core/uibase/docvw - FrameControlsManager.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 78 0.0 %
Date: 2014-04-14 Functions: 0 11 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             : 
      10             : #include <edtwin.hxx>
      11             : #include <FrameControlsManager.hxx>
      12             : #include <HeaderFooterWin.hxx>
      13             : #include <PageBreakWin.hxx>
      14             : #include <pagefrm.hxx>
      15             : #include <viewopt.hxx>
      16             : #include <view.hxx>
      17             : #include <wrtsh.hxx>
      18             : 
      19             : using namespace std;
      20             : 
      21           0 : SwFrameControlsManager::SwFrameControlsManager( SwEditWin* pEditWin ) :
      22             :     m_pEditWin( pEditWin ),
      23           0 :     m_aControls( )
      24             : {
      25           0 : }
      26             : 
      27           0 : SwFrameControlsManager::~SwFrameControlsManager()
      28             : {
      29           0 : }
      30             : 
      31           0 : SwFrameControlsManager::SwFrameControlsManager( const SwFrameControlsManager& rCopy ) :
      32             :     m_pEditWin( rCopy.m_pEditWin ),
      33           0 :     m_aControls( rCopy.m_aControls )
      34             : {
      35           0 : }
      36             : 
      37           0 : const SwFrameControlsManager& SwFrameControlsManager::operator=( const SwFrameControlsManager& rCopy )
      38             : {
      39           0 :     m_pEditWin = rCopy.m_pEditWin;
      40           0 :     m_aControls = rCopy.m_aControls;
      41           0 :     return *this;
      42             : }
      43             : 
      44           0 : SwFrameControlPtr SwFrameControlsManager::GetControl( FrameControlType eType, const SwFrm* pFrm )
      45             : {
      46           0 :     SwFrameControlPtrMap& rControls = m_aControls[eType];
      47             : 
      48           0 :     SwFrameControlPtrMap::iterator aIt = rControls.find(pFrm);
      49             : 
      50           0 :     if (aIt != rControls.end())
      51           0 :         return aIt->second;
      52             : 
      53           0 :     return SwFrameControlPtr();
      54             : }
      55             : 
      56           0 : void SwFrameControlsManager::RemoveControls( const SwFrm* pFrm )
      57             : {
      58           0 :     map< FrameControlType, SwFrameControlPtrMap >::iterator pIt = m_aControls.begin();
      59             : 
      60           0 :     while ( pIt != m_aControls.end() )
      61             :     {
      62           0 :         SwFrameControlPtrMap& rMap = pIt->second;
      63           0 :         rMap.erase(pFrm);
      64           0 :         ++pIt;
      65             :     }
      66           0 : }
      67             : 
      68           0 : void SwFrameControlsManager::RemoveControlsByType( FrameControlType eType, const SwFrm* pFrm )
      69             : {
      70           0 :     SwFrameControlPtrMap& rMap = m_aControls[eType];
      71           0 :     rMap.erase(pFrm);
      72           0 : }
      73             : 
      74           0 : void SwFrameControlsManager::HideControls( FrameControlType eType )
      75             : {
      76           0 :     SwFrameControlPtrMap::iterator pIt = m_aControls[eType].begin();
      77           0 :     while ( pIt != m_aControls[eType].end() )
      78             :     {
      79           0 :         pIt->second->ShowAll( false );
      80           0 :         ++pIt;
      81             :     }
      82           0 : }
      83             : 
      84           0 : void SwFrameControlsManager::SetReadonlyControls( bool bReadonly )
      85             : {
      86           0 :     map< FrameControlType, SwFrameControlPtrMap >::iterator pIt = m_aControls.begin();
      87             : 
      88           0 :     while ( pIt != m_aControls.end() )
      89             :     {
      90           0 :         SwFrameControlPtrMap::iterator aCtrlIt = pIt->second.begin();
      91           0 :         while ( aCtrlIt != pIt->second.end() )
      92             :         {
      93           0 :             aCtrlIt->second->SetReadonly( bReadonly );
      94           0 :             ++aCtrlIt;
      95             :         }
      96           0 :         ++pIt;
      97             :     }
      98           0 : }
      99             : 
     100           0 : void SwFrameControlsManager::SetHeaderFooterControl( const SwPageFrm* pPageFrm, FrameControlType eType, Point aOffset )
     101             : {
     102             :     OSL_ASSERT( eType == Header || eType == Footer );
     103             : 
     104             :     // Check if we already have the control
     105           0 :     SwFrameControlPtr pControl;
     106           0 :     const bool bHeader = ( eType == Header );
     107             : 
     108           0 :     SwFrameControlPtrMap& rControls = m_aControls[eType];
     109             : 
     110           0 :     SwFrameControlPtrMap::iterator lb = rControls.lower_bound(pPageFrm);
     111           0 :     if (lb != rControls.end() && !(rControls.key_comp()(pPageFrm, lb->first)))
     112           0 :         pControl = lb->second;
     113             :     else
     114             :     {
     115           0 :         SwFrameControlPtr pNewControl( new SwHeaderFooterWin( m_pEditWin, pPageFrm, bHeader ) );
     116           0 :         const SwViewOption* pViewOpt = m_pEditWin->GetView().GetWrtShell().GetViewOptions();
     117           0 :         pNewControl->SetReadonly( pViewOpt->IsReadonly() );
     118           0 :         rControls.insert(lb, make_pair(pPageFrm, pNewControl));
     119           0 :         pControl.swap( pNewControl );
     120             :     }
     121             : 
     122           0 :     Rectangle aPageRect = m_pEditWin->LogicToPixel( pPageFrm->Frm().SVRect() );
     123             : 
     124           0 :     SwHeaderFooterWin* pHFWin = dynamic_cast< SwHeaderFooterWin* >( pControl.get() );
     125             :     assert(pHFWin->IsHeader() == bHeader);
     126           0 :     pHFWin->SetOffset( aOffset, aPageRect.Left(), aPageRect.Right() );
     127             : 
     128           0 :     if ( !pHFWin->IsVisible() )
     129           0 :         pControl->ShowAll( true );
     130           0 : }
     131             : 
     132           0 : void SwFrameControlsManager::SetPageBreakControl( const SwPageFrm* pPageFrm )
     133             : {
     134             :     // Check if we already have the control
     135           0 :     SwFrameControlPtr pControl;
     136             : 
     137           0 :     SwFrameControlPtrMap& rControls = m_aControls[PageBreak];
     138             : 
     139           0 :     SwFrameControlPtrMap::iterator lb = rControls.lower_bound(pPageFrm);
     140           0 :     if (lb != rControls.end() && !(rControls.key_comp()(pPageFrm, lb->first)))
     141           0 :         pControl = lb->second;
     142             :     else
     143             :     {
     144           0 :         SwFrameControlPtr pNewControl( new SwPageBreakWin( m_pEditWin, pPageFrm ) );
     145           0 :         const SwViewOption* pViewOpt = m_pEditWin->GetView().GetWrtShell().GetViewOptions();
     146           0 :         pNewControl->SetReadonly( pViewOpt->IsReadonly() );
     147             : 
     148           0 :         rControls.insert(lb, make_pair(pPageFrm, pNewControl));
     149             : 
     150           0 :         pControl.swap( pNewControl );
     151             :     }
     152             : 
     153           0 :     SwPageBreakWin* pWin = dynamic_cast< SwPageBreakWin* >( pControl.get() );
     154           0 :     pWin->UpdatePosition();
     155           0 :     if ( !pWin->IsVisible() )
     156           0 :         pControl->ShowAll( true );
     157           0 : }
     158             : 
     159             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10