LCOV - code coverage report
Current view: top level - sd/source/ui/view - WindowUpdater.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 38 53 71.7 %
Date: 2012-08-25 Functions: 9 10 90.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 20 61 32.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "WindowUpdater.hxx"
      31                 :            : #include "ViewShell.hxx"
      32                 :            : #include "Window.hxx"
      33                 :            : #include "drawdoc.hxx"
      34                 :            : #include "View.hxx"
      35                 :            : 
      36                 :            : #include <vcl/split.hxx>
      37                 :            : #include <sfx2/childwin.hxx>
      38                 :            : #include <sfx2/viewfrm.hxx>
      39                 :            : #include <svl/smplhint.hxx>
      40                 :            : 
      41                 :            : #include <algorithm>
      42                 :            : 
      43                 :            : namespace sd {
      44                 :            : 
      45                 :        286 : WindowUpdater::WindowUpdater (void)
      46                 :            :     : mpViewShell (NULL),
      47 [ +  - ][ +  - ]:        286 :       mpDocument (NULL)
      48                 :            : {
      49         [ +  - ]:        286 :     maCTLOptions.AddListener(this);
      50                 :        286 : }
      51                 :            : 
      52                 :            : 
      53                 :            : 
      54                 :            : 
      55         [ +  - ]:        286 : WindowUpdater::~WindowUpdater (void) throw ()
      56                 :            : {
      57         [ +  - ]:        286 :     maCTLOptions.RemoveListener(this);
      58         [ -  + ]:        572 : }
      59                 :            : 
      60                 :            : 
      61                 :            : 
      62                 :            : 
      63                 :        416 : void WindowUpdater::RegisterWindow (::Window* pWindow)
      64                 :            : {
      65         [ +  - ]:        416 :     if (pWindow != NULL)
      66                 :            :     {
      67                 :            :         tWindowList::iterator aWindowIterator (
      68                 :            :             ::std::find (
      69         [ +  - ]:        416 :                 maWindowList.begin(), maWindowList.end(), pWindow));
      70 [ +  - ][ +  - ]:        416 :         if (aWindowIterator == maWindowList.end())
      71                 :            :         {
      72                 :            :             // Update the device once right now and add it to the list.
      73         [ +  - ]:        416 :             Update (pWindow);
      74         [ +  - ]:        416 :             maWindowList.push_back (pWindow);
      75                 :            :         }
      76                 :            :     }
      77                 :        416 : }
      78                 :            : 
      79                 :            : 
      80                 :            : 
      81                 :            : 
      82                 :        416 : void WindowUpdater::UnregisterWindow (::Window* pWindow)
      83                 :            : {
      84                 :            :     tWindowList::iterator aWindowIterator (
      85                 :            :         ::std::find (
      86         [ +  - ]:        416 :             maWindowList.begin(), maWindowList.end(), pWindow));
      87 [ +  - ][ +  - ]:        416 :     if (aWindowIterator != maWindowList.end())
      88                 :            :     {
      89         [ +  - ]:        416 :         maWindowList.erase (aWindowIterator);
      90                 :            :     }
      91                 :        416 : }
      92                 :            : 
      93                 :            : 
      94                 :            : 
      95                 :        286 : void WindowUpdater::SetViewShell (ViewShell& rViewShell)
      96                 :            : {
      97                 :        286 :     mpViewShell = &rViewShell;
      98                 :        286 : }
      99                 :            : 
     100                 :            : 
     101                 :            : 
     102                 :            : 
     103                 :        286 : void WindowUpdater::SetDocument (SdDrawDocument* pDocument)
     104                 :            : {
     105                 :        286 :     mpDocument = pDocument;
     106                 :        286 : }
     107                 :            : 
     108                 :            : 
     109                 :            : 
     110                 :            : 
     111                 :        416 : void WindowUpdater::Update (
     112                 :            :     OutputDevice* pDevice,
     113                 :            :     SdDrawDocument* pDocument) const
     114                 :            : {
     115         [ +  - ]:        416 :     if (pDevice != NULL)
     116                 :            :     {
     117                 :        416 :         UpdateWindow (pDevice);
     118         [ -  + ]:        416 :         if (pDocument != NULL)
     119                 :          0 :             pDocument->ReformatAllTextObjects();
     120                 :            :     }
     121                 :        416 : }
     122                 :            : 
     123                 :            : 
     124                 :            : 
     125                 :            : 
     126                 :        416 : void WindowUpdater::UpdateWindow (OutputDevice* pDevice) const
     127                 :            : {
     128         [ +  - ]:        416 :     if (pDevice != NULL)
     129                 :            :     {
     130                 :        416 :         SvtCTLOptions::TextNumerals aNumeralMode (maCTLOptions.GetCTLTextNumerals());
     131                 :            : 
     132                 :            :         LanguageType aLanguage;
     133                 :            :         // Now this is a bit confusing.  The numerals in arabic languages
     134                 :            :         // are Hindi numerals and what the western world generally uses are
     135                 :            :         // arabic numerals.  The digits used in the Hindi language are not
     136                 :            :         // used at all.
     137      [ -  -  + ]:        416 :         switch (aNumeralMode)
     138                 :            :         {
     139                 :            :             case SvtCTLOptions::NUMERALS_HINDI:
     140                 :          0 :                 aLanguage = LANGUAGE_ARABIC_SAUDI_ARABIA;
     141                 :          0 :                 break;
     142                 :            : 
     143                 :            :             case SvtCTLOptions::NUMERALS_SYSTEM:
     144                 :          0 :                 aLanguage = LANGUAGE_SYSTEM;
     145                 :          0 :                 break;
     146                 :            : 
     147                 :            :             case SvtCTLOptions::NUMERALS_ARABIC:
     148                 :            :             default:
     149                 :        416 :                 aLanguage = LANGUAGE_ENGLISH;
     150                 :        416 :                 break;
     151                 :            :         }
     152                 :            : 
     153                 :        416 :         pDevice->SetDigitLanguage (aLanguage);
     154                 :            :     }
     155                 :        416 : }
     156                 :            : 
     157                 :            : 
     158                 :            : 
     159                 :            : 
     160                 :          0 : void WindowUpdater::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
     161                 :            : {
     162                 :            :     // Set the current state at all registered output devices.
     163                 :          0 :     tWindowList::iterator aWindowIterator (maWindowList.begin());
     164 [ #  # ][ #  # ]:          0 :     while (aWindowIterator != maWindowList.end())
     165 [ #  # ][ #  # ]:          0 :         Update (*aWindowIterator++);
     166                 :            : 
     167                 :            :     // Reformat the document for the modified state to take effect.
     168         [ #  # ]:          0 :     if (mpDocument != NULL)
     169         [ #  # ]:          0 :         mpDocument->ReformatAllTextObjects();
     170                 :            : 
     171                 :            :     // Invalidate the windows to make the modified state visible.
     172                 :          0 :     aWindowIterator = maWindowList.begin();
     173 [ #  # ][ #  # ]:          0 :     while (aWindowIterator != maWindowList.end())
     174 [ #  # ][ #  # ]:          0 :         (*aWindowIterator++)->Invalidate();
     175                 :          0 : }
     176                 :            : 
     177                 :            : 
     178                 :            : } // end of namespace sd
     179                 :            : 
     180                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10