LCOV - code coverage report
Current view: top level - reportdesign/source/ui/report - FixedTextColor.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 4 73 5.5 %
Date: 2014-11-03 Functions: 3 11 27.3 %
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             : 
      21             : #include <FixedTextColor.hxx>
      22             : #include <com/sun/star/report/XFixedText.hpp>
      23             : #include <com/sun/star/awt/XVclWindowPeer.hpp>
      24             : #include <com/sun/star/awt/InvalidateStyle.hpp>
      25             : 
      26             : #include <RptObject.hxx>
      27             : #include <RptModel.hxx>
      28             : #include <RptPage.hxx>
      29             : #include <ViewsWindow.hxx>
      30             : #include <ReportSection.hxx>
      31             : #include <ReportController.hxx>
      32             : #include <uistrings.hrc>
      33             : #include <reportformula.hxx>
      34             : #include <toolkit/helper/property.hxx>
      35             : 
      36             : #include <tools/color.hxx>
      37             : #include <svtools/extcolorcfg.hxx>
      38             : #include <unotools/confignode.hxx>
      39             : 
      40             : // DBG_*
      41             : #include <tools/debug.hxx>
      42             : // DBG_UNHANDLED_EXCEPTION
      43             : #include <tools/diagnose_ex.h>
      44             : 
      45             : #include <vcl/svapp.hxx>
      46             : #include <vcl/settings.hxx>
      47             : 
      48             : namespace rptui
      49             : {
      50             :     using namespace ::com::sun::star;
      51             : 
      52             : 
      53           2 :     FixedTextColor::FixedTextColor(const OReportController& _aController)
      54           2 :             :m_rReportController(_aController)
      55             :     {
      56           2 :     }
      57             : 
      58             : 
      59           0 :     FixedTextColor::~FixedTextColor()
      60             :     {
      61           0 :     }
      62             : 
      63             : 
      64           0 :     void FixedTextColor::notifyPropertyChange( const beans::PropertyChangeEvent& _rEvent )
      65             :     {
      66           0 :         uno::Reference< report::XFixedText > xFixedText( _rEvent.Source, uno::UNO_QUERY );
      67           0 :         if ( ! xFixedText.is() )
      68             :         {
      69           0 :             return;
      70             :         }
      71             : 
      72             :         try
      73             :         {
      74           0 :             uno::Reference< lang::XComponent > xComponent( xFixedText, uno::UNO_QUERY_THROW );
      75           0 :             handle(xComponent);
      76             :         }
      77           0 :         catch (uno::Exception const&)
      78             :         {
      79             :             DBG_UNHANDLED_EXCEPTION();
      80           0 :         }
      81             :     }
      82             : 
      83             : 
      84           0 :     void FixedTextColor::setPropertyTextColor(const uno::Reference< awt::XVclWindowPeer >& _xVclWindowPeer, sal_Int32 _nTextColor)
      85             :     {
      86           0 :         _xVclWindowPeer->setProperty(PROPERTY_TEXTCOLOR, uno::makeAny(sal_Int32(_nTextColor)));
      87           0 :     }
      88             : 
      89             : 
      90           0 :     void FixedTextColor::notifyElementInserted( const uno::Reference< uno::XInterface >& _rxElement )
      91             :     {
      92           0 :         handle(_rxElement);
      93           0 :     }
      94             : 
      95             : 
      96           0 :     void FixedTextColor::handle( const uno::Reference< uno::XInterface >& _rxElement )
      97             :     {
      98           0 :         uno::Reference< report::XFixedText > xFixedText( _rxElement, uno::UNO_QUERY );
      99           0 :         if ( ! xFixedText.is() )
     100             :         {
     101           0 :             return;
     102             :         }
     103             : 
     104             :         try
     105             :         {
     106           0 :             bool bIsDark = false;
     107           0 :             const sal_Int32 nBackColor( xFixedText->getControlBackground() );
     108           0 :             if ((sal_uInt32)nBackColor == COL_TRANSPARENT)
     109             :             {
     110           0 :                 uno::Reference <report::XSection> xSection(xFixedText->getParent(), uno::UNO_QUERY_THROW);
     111             : 
     112           0 :                 bool bSectionBackColorIsTransparent = xSection->getBackTransparent();
     113           0 :                 if (bSectionBackColorIsTransparent)
     114             :                 {
     115             :                     // Label Transparent, Section Transparent set LabelTextColor
     116           0 :                     const StyleSettings& aStyleSettings = Application::GetSettings().GetStyleSettings();
     117           0 :                     Color aWindowColor  = aStyleSettings.GetWindowColor();
     118           0 :                     bIsDark = aWindowColor.IsDark();
     119             :                 }
     120             :                 else
     121             :                 {
     122           0 :                     com::sun::star::util::Color aColor2 = xSection->getBackColor();
     123           0 :                     Color aBackColor(aColor2);
     124           0 :                     bIsDark = aBackColor.IsDark();
     125           0 :                 }
     126             :             }
     127             :             else
     128             :             {
     129           0 :                 Color aLabelBackColor(nBackColor);
     130           0 :                 bIsDark = aLabelBackColor.IsDark();
     131             :             }
     132             : 
     133           0 :             uno::Reference<awt::XVclWindowPeer> xVclWindowPeer = getVclWindowPeer(xFixedText);
     134           0 :             if (bIsDark)
     135             :             {
     136           0 :                 const StyleSettings& aStyleSettings = Application::GetSettings().GetStyleSettings();
     137           0 :                 Color aLabelTextColor  = aStyleSettings.GetLabelTextColor();
     138           0 :                 setPropertyTextColor(xVclWindowPeer, aLabelTextColor.GetColor());
     139             :             }
     140             :             else
     141             :             {
     142           0 :                 util::Color aLabelColor = xFixedText->getCharColor();
     143           0 :                 setPropertyTextColor(xVclWindowPeer, aLabelColor);
     144           0 :             }
     145             : 
     146             :         }
     147           0 :         catch( const uno::Exception& )
     148             :         {
     149             :             DBG_UNHANDLED_EXCEPTION();
     150           0 :         }
     151             :     }
     152             : 
     153             : 
     154             : 
     155             :     // XPropertyChangeListener
     156           0 :     uno::Reference<awt::XControl> FixedTextColor::getXControl(const uno::Reference< report::XFixedText >& _xFixedText) throw(uno::RuntimeException)
     157             :     {
     158             : 
     159           0 :         uno::Reference<awt::XControl> xControl;
     160           0 :         OReportController *pController = (OReportController *)&m_rReportController;
     161             : 
     162           0 :         ::boost::shared_ptr<OReportModel> pModel = pController->getSdrModel();
     163             : 
     164           0 :             uno::Reference<report::XSection> xSection(_xFixedText->getSection());
     165           0 :             if ( xSection.is() )
     166             :             {
     167           0 :                 OReportPage *pPage = pModel->getPage(xSection);
     168           0 :                 const size_t nIndex = pPage->getIndexOf(_xFixedText.get());
     169           0 :                 if (nIndex < pPage->GetObjCount() )
     170             :                 {
     171           0 :                     SdrObject *pObject = pPage->GetObj(nIndex);
     172           0 :                     OUnoObject* pUnoObj = dynamic_cast<OUnoObject*>(pObject);
     173           0 :                     if ( pUnoObj ) // this doesn't need to be done for shapes
     174             :                     {
     175           0 :                         ::boost::shared_ptr<OSectionWindow> pSectionWindow = pController->getSectionWindow(xSection);
     176           0 :                         if (pSectionWindow != 0)
     177             :                         {
     178           0 :                             OReportSection& aOutputDevice = pSectionWindow->getReportSection(); // OutputDevice
     179           0 :                             OSectionView& aSdrView = aOutputDevice.getSectionView(); // SdrView
     180           0 :                             xControl = pUnoObj->GetUnoControl(aSdrView, aOutputDevice);
     181           0 :                         }
     182             :                     }
     183             :                 }
     184             :             }
     185           0 :         return xControl;
     186             :     }
     187             : 
     188             : 
     189           0 :     uno::Reference<awt::XVclWindowPeer> FixedTextColor::getVclWindowPeer(const uno::Reference< report::XFixedText >& _xComponent) throw(uno::RuntimeException)
     190             :     {
     191           0 :         uno::Reference<awt::XVclWindowPeer> xVclWindowPeer;
     192           0 :         uno::Reference<awt::XControl> xControl = getXControl(_xComponent);
     193             : 
     194           0 :         xVclWindowPeer = uno::Reference<awt::XVclWindowPeer>( xControl->getPeer(), uno::UNO_QUERY);
     195             : 
     196           0 :         return xVclWindowPeer;
     197             :     }
     198             : 
     199             : 
     200             : 
     201             : 
     202           6 : }
     203             : 
     204             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10