LCOV - code coverage report
Current view: top level - reportdesign/source/core/misc - conditionupdater.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 42 0.0 %
Date: 2012-08-25 Functions: 0 5 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 74 0.0 %

           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                 :            : #include "conditionupdater.hxx"
      29                 :            : #include "reportformula.hxx"
      30                 :            : 
      31                 :            : #include <com/sun/star/report/XFormatCondition.hpp>
      32                 :            : 
      33                 :            : #include <tools/diagnose_ex.h>
      34                 :            : 
      35                 :            : //........................................................................
      36                 :            : namespace rptui
      37                 :            : {
      38                 :            : //........................................................................
      39                 :            : 
      40                 :            :     /** === begin UNO using === **/
      41                 :            :     using ::com::sun::star::beans::PropertyChangeEvent;
      42                 :            :     using ::com::sun::star::uno::Reference;
      43                 :            :     using ::com::sun::star::report::XReportControlModel;
      44                 :            :     using ::com::sun::star::uno::UNO_QUERY;
      45                 :            :     using ::com::sun::star::report::XFormatCondition;
      46                 :            :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      47                 :            :     using ::com::sun::star::uno::Exception;
      48                 :            :     /** === end UNO using === **/
      49                 :            : 
      50                 :            :     //====================================================================
      51                 :            :     //= ConditionUpdater
      52                 :            :     //====================================================================
      53                 :            :     //--------------------------------------------------------------------
      54         [ #  # ]:          0 :     ConditionUpdater::ConditionUpdater()
      55                 :            :     {
      56                 :          0 :     }
      57                 :            : 
      58                 :            :     //--------------------------------------------------------------------
      59                 :          0 :     ConditionUpdater::~ConditionUpdater()
      60                 :            :     {
      61                 :          0 :     }
      62                 :            : 
      63                 :            :     //--------------------------------------------------------------------
      64                 :          0 :     void ConditionUpdater::notifyPropertyChange( const PropertyChangeEvent& _rEvent )
      65                 :            :     {
      66 [ #  # ][ #  # ]:          0 :         if ( !impl_lateInit_nothrow() )
      67                 :          0 :             return;
      68                 :            : 
      69         [ #  # ]:          0 :         Reference< XReportControlModel > xRptControlModel( _rEvent.Source, UNO_QUERY );
      70 [ #  # ][ #  # ]:          0 :         if ( xRptControlModel.is() && _rEvent.PropertyName == "DataField" )
                 [ #  # ]
      71                 :            :         {
      72                 :          0 :             ::rtl::OUString sOldDataSource, sNewDataSource;
      73                 :          0 :             OSL_VERIFY( _rEvent.OldValue >>= sOldDataSource );
      74                 :          0 :             OSL_VERIFY( _rEvent.NewValue >>= sNewDataSource );
      75         [ #  # ]:          0 :             impl_adjustFormatConditions_nothrow( xRptControlModel, sOldDataSource, sNewDataSource );
      76                 :          0 :         }
      77                 :            :     }
      78                 :            : 
      79                 :            :     //--------------------------------------------------------------------
      80                 :          0 :     bool ConditionUpdater::impl_lateInit_nothrow()
      81                 :            :     {
      82         [ #  # ]:          0 :         if ( !m_aConditionalExpressions.empty() )
      83                 :          0 :             return true;
      84                 :            : 
      85                 :          0 :         ConditionalExpressionFactory::getKnownConditionalExpressions( m_aConditionalExpressions );
      86                 :          0 :         return true;
      87                 :            :     }
      88                 :            : 
      89                 :            :     //--------------------------------------------------------------------
      90                 :          0 :     void ConditionUpdater::impl_adjustFormatConditions_nothrow( const Reference< XReportControlModel >& _rxRptControlModel,
      91                 :            :         const ::rtl::OUString& _rOldDataSource, const ::rtl::OUString& _rNewDataSource )
      92                 :            :     {
      93                 :            :         try
      94                 :            :         {
      95         [ #  # ]:          0 :             ReportFormula aOldContentFormula( _rOldDataSource );
      96         [ #  # ]:          0 :             ::rtl::OUString sOldUnprefixed( aOldContentFormula.getBracketedFieldOrExpression() );
      97         [ #  # ]:          0 :             ReportFormula aNewContentFormula( _rNewDataSource );
      98         [ #  # ]:          0 :             ::rtl::OUString sNewUnprefixed( aNewContentFormula.getBracketedFieldOrExpression() );
      99                 :            : 
     100 [ #  # ][ #  # ]:          0 :             sal_Int32 nCount( _rxRptControlModel->getCount() );
     101                 :          0 :             Reference< XFormatCondition > xFormatCondition;
     102                 :          0 :             ::rtl::OUString sFormulaExpression, sLHS, sRHS;
     103         [ #  # ]:          0 :             for ( sal_Int32 i=0; i<nCount; ++i )
     104                 :            :             {
     105 [ #  # ][ #  # ]:          0 :                 xFormatCondition.set( _rxRptControlModel->getByIndex( i ), UNO_QUERY_THROW );
                 [ #  # ]
     106 [ #  # ][ #  # ]:          0 :                 ReportFormula aFormula( xFormatCondition->getFormula() );
                 [ #  # ]
     107         [ #  # ]:          0 :                 sFormulaExpression = aFormula.getExpression();
     108                 :            : 
     109         [ #  # ]:          0 :                 for (   ConditionalExpressions::const_iterator loop = m_aConditionalExpressions.begin();
     110                 :          0 :                         loop != m_aConditionalExpressions.end();
     111                 :            :                         ++loop
     112                 :            :                     )
     113                 :            :                 {
     114 [ #  # ][ #  # ]:          0 :                     if ( !loop->second->matchExpression( sFormulaExpression, sOldUnprefixed, sLHS, sRHS ) )
     115                 :          0 :                         continue;
     116                 :            : 
     117                 :            :                     // the expression matches -> translate it to the new data source of the report control model
     118         [ #  # ]:          0 :                     sFormulaExpression = loop->second->assembleExpression( sNewUnprefixed, sLHS, sRHS );
     119 [ #  # ][ #  # ]:          0 :                     aFormula = ReportFormula( ReportFormula::Expression, sFormulaExpression );
                 [ #  # ]
     120 [ #  # ][ #  # ]:          0 :                     xFormatCondition->setFormula( aFormula.getCompleteFormula() );
                 [ #  # ]
     121                 :          0 :                     break;
     122                 :            :                 }
     123 [ #  # ][ #  # ]:          0 :             }
         [ #  # ][ #  # ]
     124                 :            :         }
     125                 :          0 :         catch( const Exception& )
     126                 :            :         {
     127                 :            :             DBG_UNHANDLED_EXCEPTION();
     128                 :            :         }
     129                 :          0 :     }
     130                 :            : 
     131                 :            : //........................................................................
     132                 :            : } // namespace rptui
     133                 :            : //........................................................................
     134                 :            : 
     135                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10