LCOV - code coverage report
Current view: top level - libreoffice/reportdesign/source/ui/report - FixedTextColor.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 72 0.0 %
Date: 2012-12-27 Functions: 0 9 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             : 
      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> // COL_TRANSPARENT
      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             :     DBG_NAME(rpt_FixedTextColor)
      53             : 
      54           0 :     FixedTextColor::FixedTextColor(const OReportController& _aController)
      55           0 :             :m_rReportController(_aController)
      56             :     {
      57             :         DBG_CTOR(rpt_FixedTextColor, NULL);
      58           0 :     }
      59             : 
      60             :     //--------------------------------------------------------------------
      61           0 :     FixedTextColor::~FixedTextColor()
      62             :     {
      63             :         DBG_DTOR(rpt_FixedTextColor,NULL);
      64           0 :     }
      65             :     // -----------------------------------------------------------------------------
      66             : 
      67           0 :     void FixedTextColor::notifyPropertyChange( const beans::PropertyChangeEvent& _rEvent )
      68             :     {
      69           0 :         uno::Reference< report::XFixedText > xFixedText( _rEvent.Source, uno::UNO_QUERY );
      70           0 :         if ( ! xFixedText.is() )
      71             :         {
      72           0 :             return;
      73             :         }
      74             : 
      75             :         try
      76             :         {
      77           0 :             uno::Reference< lang::XComponent > xComponent( xFixedText, uno::UNO_QUERY_THROW );
      78           0 :             handle(xComponent);
      79             :         }
      80           0 :         catch (uno::Exception const&)
      81             :         {
      82             :             DBG_UNHANDLED_EXCEPTION();
      83           0 :         }
      84             :     }
      85             : 
      86             :     // -----------------------------------------------------------------------------
      87           0 :     void FixedTextColor::setPropertyTextColor(const uno::Reference< awt::XVclWindowPeer >& _xVclWindowPeer, sal_Int32 _nTextColor)
      88             :     {
      89           0 :         _xVclWindowPeer->setProperty(PROPERTY_TEXTCOLOR, uno::makeAny(sal_Int32(_nTextColor)));
      90           0 :     }
      91             : 
      92             :     // -----------------------------------------------------------------------------
      93           0 :     void FixedTextColor::notifyElementInserted( const uno::Reference< uno::XInterface >& _rxElement )
      94             :     {
      95           0 :         handle(_rxElement);
      96           0 :     }
      97             : 
      98             : // -----------------------------------------------------------------------------
      99           0 :     void FixedTextColor::handle( const uno::Reference< uno::XInterface >& _rxElement )
     100             :     {
     101           0 :         uno::Reference< report::XFixedText > xFixedText( _rxElement, uno::UNO_QUERY );
     102           0 :         if ( ! xFixedText.is() )
     103             :         {
     104           0 :             return;
     105             :         }
     106             : 
     107             :         try
     108             :         {
     109           0 :             sal_Bool bIsDark = sal_False;
     110           0 :             const sal_Int32 nBackColor( xFixedText->getControlBackground() );
     111           0 :             if ((sal_uInt32)nBackColor == COL_TRANSPARENT)
     112             :             {
     113           0 :                 uno::Reference <report::XSection> xSection(xFixedText->getParent(), uno::UNO_QUERY_THROW);
     114             : 
     115           0 :                 sal_Bool bSectionBackColorIsTransparent = xSection->getBackTransparent();
     116           0 :                 if (bSectionBackColorIsTransparent)
     117             :                 {
     118             :                     // Label Transparent, Section Transparent set LabelTextColor
     119           0 :                     const StyleSettings& aStyleSettings = Application::GetSettings().GetStyleSettings();
     120           0 :                     Color aWindowColor  = aStyleSettings.GetWindowColor();
     121           0 :                     bIsDark = aWindowColor.IsDark();
     122             :                 }
     123             :                 else
     124             :                 {
     125           0 :                     com::sun::star::util::Color aColor2 = xSection->getBackColor();
     126           0 :                     Color aBackColor(aColor2);
     127           0 :                     bIsDark = aBackColor.IsDark();
     128           0 :                 }
     129             :             }
     130             :             else
     131             :             {
     132           0 :                 Color aLabelBackColor(nBackColor);
     133           0 :                 bIsDark = aLabelBackColor.IsDark();
     134             :             }
     135             : 
     136           0 :             uno::Reference<awt::XVclWindowPeer> xVclWindowPeer = getVclWindowPeer(xFixedText);
     137           0 :             if (bIsDark)
     138             :             {
     139           0 :                 const StyleSettings& aStyleSettings = Application::GetSettings().GetStyleSettings();
     140           0 :                 Color aLabelTextColor  = aStyleSettings.GetLabelTextColor();
     141           0 :                 setPropertyTextColor(xVclWindowPeer, aLabelTextColor.GetColor());
     142             :             }
     143             :             else
     144             :             {
     145           0 :                 util::Color aLabelColor = xFixedText->getCharColor();
     146           0 :                 setPropertyTextColor(xVclWindowPeer, aLabelColor);
     147           0 :             }
     148             : 
     149             :         }
     150           0 :         catch( const uno::Exception& )
     151             :         {
     152             :             DBG_UNHANDLED_EXCEPTION();
     153           0 :         }
     154             :     }
     155             : 
     156             : 
     157             : // -----------------------------------------------------------------------------
     158             :     // XPropertyChangeListener
     159           0 :     uno::Reference<awt::XControl> FixedTextColor::getXControl(const uno::Reference< report::XFixedText >& _xFixedText) throw(uno::RuntimeException)
     160             :     {
     161             : 
     162           0 :         uno::Reference<awt::XControl> xControl;
     163           0 :         OReportController *pController = (OReportController *)&m_rReportController;
     164             : 
     165           0 :         ::boost::shared_ptr<OReportModel> pModel = pController->getSdrModel();
     166             : 
     167           0 :             uno::Reference<report::XSection> xSection(_xFixedText->getSection());
     168           0 :             if ( xSection.is() )
     169             :             {
     170           0 :                 OReportPage *pPage = pModel->getPage(xSection);
     171           0 :                 sal_uLong nIndex = pPage->getIndexOf(_xFixedText.get());
     172           0 :                 if (nIndex < pPage->GetObjCount() )
     173             :                 {
     174           0 :                     SdrObject *pObject = pPage->GetObj(nIndex);
     175           0 :                     OUnoObject* pUnoObj = dynamic_cast<OUnoObject*>(pObject);
     176           0 :                     if ( pUnoObj ) // this doesn't need to be done for shapes
     177             :                     {
     178           0 :                         ::boost::shared_ptr<OSectionWindow> pSectionWindow = pController->getSectionWindow(xSection);
     179           0 :                         if (pSectionWindow != NULL)
     180             :                         {
     181           0 :                             OReportSection& aOutputDevice = pSectionWindow->getReportSection(); // OutputDevice
     182           0 :                             OSectionView& aSdrView = aOutputDevice.getSectionView(); // SdrView
     183           0 :                             xControl = pUnoObj->GetUnoControl(aSdrView, aOutputDevice);
     184           0 :                         }
     185             :                     }
     186             :                 }
     187             :             }
     188           0 :         return xControl;
     189             :     }
     190             : 
     191             : // -----------------------------------------------------------------------------
     192           0 :     uno::Reference<awt::XVclWindowPeer> FixedTextColor::getVclWindowPeer(const uno::Reference< report::XFixedText >& _xComponent) throw(uno::RuntimeException)
     193             :     {
     194           0 :         uno::Reference<awt::XVclWindowPeer> xVclWindowPeer;
     195           0 :         uno::Reference<awt::XControl> xControl = getXControl(_xComponent);
     196             : 
     197           0 :         xVclWindowPeer = uno::Reference<awt::XVclWindowPeer>( xControl->getPeer(), uno::UNO_QUERY);
     198             : 
     199           0 :         return xVclWindowPeer;
     200             :     }
     201             : 
     202             : 
     203             : 
     204             : 
     205             : }
     206             : 
     207             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10