LCOV - code coverage report
Current view: top level - sd/source/ui/view - WindowUpdater.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 39 54 72.2 %
Date: 2015-06-13 12:38:46 Functions: 11 12 91.7 %
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 "WindowUpdater.hxx"
      21             : #include "ViewShell.hxx"
      22             : #include "Window.hxx"
      23             : #include "drawdoc.hxx"
      24             : #include "View.hxx"
      25             : 
      26             : #include <vcl/split.hxx>
      27             : #include <sfx2/childwin.hxx>
      28             : #include <sfx2/viewfrm.hxx>
      29             : #include <svl/smplhint.hxx>
      30             : 
      31             : #include <algorithm>
      32             : 
      33             : namespace sd {
      34             : 
      35         197 : WindowUpdater::WindowUpdater()
      36             :     : mpViewShell (NULL),
      37         197 :       mpDocument (NULL)
      38             : {
      39         197 :     maCTLOptions.AddListener(this);
      40         197 : }
      41             : 
      42         591 : WindowUpdater::~WindowUpdater() throw ()
      43             : {
      44         197 :     maCTLOptions.RemoveListener(this);
      45         394 : }
      46             : 
      47         261 : void WindowUpdater::RegisterWindow (vcl::Window* pWindow)
      48             : {
      49         261 :     if (pWindow != NULL)
      50             :     {
      51             :         tWindowList::iterator aWindowIterator (
      52             :             ::std::find (
      53         261 :                 maWindowList.begin(), maWindowList.end(), pWindow));
      54         261 :         if (aWindowIterator == maWindowList.end())
      55             :         {
      56             :             // Update the device once right now and add it to the list.
      57         261 :             Update (pWindow);
      58         261 :             maWindowList.push_back (pWindow);
      59             :         }
      60             :     }
      61         261 : }
      62             : 
      63         261 : void WindowUpdater::UnregisterWindow (vcl::Window* pWindow)
      64             : {
      65             :     tWindowList::iterator aWindowIterator (
      66             :         ::std::find (
      67         261 :             maWindowList.begin(), maWindowList.end(), pWindow));
      68         261 :     if (aWindowIterator != maWindowList.end())
      69             :     {
      70         261 :         maWindowList.erase (aWindowIterator);
      71             :     }
      72         261 : }
      73             : 
      74         197 : void WindowUpdater::SetViewShell (ViewShell& rViewShell)
      75             : {
      76         197 :     mpViewShell = &rViewShell;
      77         197 : }
      78             : 
      79         197 : void WindowUpdater::SetDocument (SdDrawDocument* pDocument)
      80             : {
      81         197 :     mpDocument = pDocument;
      82         197 : }
      83             : 
      84         261 : void WindowUpdater::Update (
      85             :     OutputDevice* pDevice,
      86             :     SdDrawDocument* pDocument) const
      87             : {
      88         261 :     if (pDevice != NULL)
      89             :     {
      90         261 :         UpdateWindow (pDevice);
      91         261 :         if (pDocument != NULL)
      92           0 :             pDocument->ReformatAllTextObjects();
      93             :     }
      94         261 : }
      95             : 
      96         261 : void WindowUpdater::UpdateWindow (OutputDevice* pDevice) const
      97             : {
      98         261 :     if (pDevice != NULL)
      99             :     {
     100         261 :         SvtCTLOptions::TextNumerals aNumeralMode (maCTLOptions.GetCTLTextNumerals());
     101             : 
     102             :         LanguageType aLanguage;
     103             :         // Now this is a bit confusing.  The numerals in arabic languages
     104             :         // are Hindi numerals and what the western world generally uses are
     105             :         // arabic numerals.  The digits used in the Hindi language are not
     106             :         // used at all.
     107         261 :         switch (aNumeralMode)
     108             :         {
     109             :             case SvtCTLOptions::NUMERALS_HINDI:
     110           0 :                 aLanguage = LANGUAGE_ARABIC_SAUDI_ARABIA;
     111           0 :                 break;
     112             : 
     113             :             case SvtCTLOptions::NUMERALS_SYSTEM:
     114           0 :                 aLanguage = LANGUAGE_SYSTEM;
     115           0 :                 break;
     116             : 
     117             :             case SvtCTLOptions::NUMERALS_ARABIC:
     118             :             default:
     119         261 :                 aLanguage = LANGUAGE_ENGLISH;
     120         261 :                 break;
     121             :         }
     122             : 
     123         261 :         pDevice->SetDigitLanguage (aLanguage);
     124             :     }
     125         261 : }
     126             : 
     127           0 : void WindowUpdater::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
     128             : {
     129             :     // Set the current state at all registered output devices.
     130           0 :     tWindowList::iterator aWindowIterator (maWindowList.begin());
     131           0 :     while (aWindowIterator != maWindowList.end())
     132           0 :         Update (*aWindowIterator++);
     133             : 
     134             :     // Reformat the document for the modified state to take effect.
     135           0 :     if (mpDocument != NULL)
     136           0 :         mpDocument->ReformatAllTextObjects();
     137             : 
     138             :     // Invalidate the windows to make the modified state visible.
     139           0 :     aWindowIterator = maWindowList.begin();
     140           0 :     while (aWindowIterator != maWindowList.end())
     141           0 :         (*aWindowIterator++)->Invalidate();
     142           0 : }
     143             : 
     144          66 : } // end of namespace sd
     145             : 
     146             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11