LCOV - code coverage report
Current view: top level - reportdesign/source/ui/dlg - Condition.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 306 0.3 %
Date: 2015-06-13 12:38:46 Functions: 2 41 4.9 %
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 "Condition.hxx"
      21             : #include "UITools.hxx"
      22             : #include "CondFormat.hxx"
      23             : #include "CondFormat.hrc"
      24             : #include "RptResId.hrc"
      25             : #include "ReportController.hxx"
      26             : #include "ModuleHelper.hxx"
      27             : #include "ColorChanger.hxx"
      28             : #include "helpids.hrc"
      29             : #include "reportformula.hxx"
      30             : #include <com/sun/star/util/URL.hpp>
      31             : #include <com/sun/star/beans/PropertyValue.hpp>
      32             : #include <com/sun/star/ui/XUIConfigurationManager.hpp>
      33             : #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
      34             : #include <com/sun/star/ui/XImageManager.hpp>
      35             : #include <com/sun/star/awt/FontDescriptor.hpp>
      36             : #include <com/sun/star/ui/ImageType.hpp>
      37             : 
      38             : #include <svx/tbcontrl.hxx>
      39             : #include <svx/svxids.hrc>
      40             : #include <svx/xtable.hxx>
      41             : #include <svx/tbxcolorupdate.hxx>
      42             : #include <toolkit/helper/vclunohelper.hxx>
      43             : #include <svtools/imgdef.hxx>
      44             : #include <unotools/pathoptions.hxx>
      45             : #include <vcl/svapp.hxx>
      46             : #include <vcl/bmpacc.hxx>
      47             : #include <vcl/settings.hxx>
      48             : 
      49             : #include <tools/diagnose_ex.h>
      50             : #include <rtl/ustrbuf.hxx>
      51             : #include <svtools/valueset.hxx>
      52             : 
      53             : namespace rptui
      54             : {
      55             : using namespace ::com::sun::star;
      56             : using namespace ::com::sun::star::uno;
      57             : using namespace ::com::sun::star::beans;
      58             : 
      59           0 : ConditionField::ConditionField(Condition* pParent, Edit* pSubEdit, PushButton *pFormula)
      60             :     : m_pParent(pParent)
      61             :     , m_pSubEdit(pSubEdit)
      62           0 :     , m_pFormula(pFormula)
      63             : {
      64           0 :     m_pSubEdit->EnableRTL( false );
      65             : 
      66           0 :     m_pFormula->SetText(OUString("..."));
      67           0 :     m_pFormula->SetClickHdl( LINK( this, ConditionField, OnFormula ) );
      68           0 : }
      69             : 
      70           0 : IMPL_LINK( ConditionField, OnFormula, Button*, _pClickedButton )
      71             : {
      72           0 :     OUString sFormula(m_pSubEdit->GetText());
      73           0 :     const sal_Int32 nLen = sFormula.getLength();
      74           0 :     if ( nLen )
      75             :     {
      76           0 :         ReportFormula aFormula( sFormula );
      77           0 :         sFormula = aFormula.getCompleteFormula();
      78             :     }
      79           0 :     uno::Reference< awt::XWindow> xInspectorWindow = VCLUnoHelper::GetInterface(_pClickedButton);
      80           0 :     uno::Reference< beans::XPropertySet> xProp(m_pParent->getController().getRowSet(),uno::UNO_QUERY);
      81           0 :     if ( rptui::openDialogFormula_nothrow( sFormula, m_pParent->getController().getContext(),xInspectorWindow,xProp ) )
      82             :     {
      83           0 :         ReportFormula aFormula( sFormula );
      84           0 :         m_pSubEdit->SetText(aFormula.getUndecoratedContent());
      85             :     }
      86           0 :     return 0L;
      87             : }
      88             : 
      89             : // class SvxColorWindow_Impl --------------------------------------------------
      90             : #ifndef WB_NO_DIRECTSELECT
      91             : #define WB_NO_DIRECTSELECT      ((WinBits)0x04000000)
      92             : #endif
      93             : 
      94             : #define PALETTE_X 10
      95             : #define PALETTE_Y 10
      96             : #define PALETTE_SIZE (PALETTE_X * PALETTE_Y)
      97             : class OColorPopup : public FloatingWindow
      98             : {
      99             :     DECL_LINK( SelectHdl, void * );
     100             :     VclPtr<Condition>      m_pCondition;
     101             :     sal_uInt16      m_nSlotId;
     102             : public:
     103             :     OColorPopup(vcl::Window* _pParent,Condition* _pCondition);
     104             :     virtual ~OColorPopup();
     105             :     virtual void dispose() SAL_OVERRIDE;
     106             :     VclPtr<ValueSet>        m_aColorSet;
     107             : 
     108             :     virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     109             :     virtual void Resize() SAL_OVERRIDE;
     110             : 
     111             :     void StartSelection();
     112             :     void SetSlotId(sal_uInt16 _nSlotId);
     113             : };
     114             : 
     115           0 : OColorPopup::OColorPopup(vcl::Window* _pParent,Condition* _pCondition)
     116             : :FloatingWindow(_pParent, WinBits( WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK|WB_DIALOGCONTROL ))
     117             : ,m_pCondition(_pCondition)
     118             : ,m_nSlotId(0)
     119           0 : ,m_aColorSet( VclPtr<ValueSet>::Create(this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT)) )
     120             : {
     121           0 :     m_aColorSet->SetHelpId( HID_RPT_POPUP_COLOR_CTRL );
     122           0 :     SetHelpId( HID_RPT_POPUP_COLOR );
     123           0 :     const Size aSize12( 13, 13 );
     124           0 :     short i = 0;
     125           0 :     XColorListRef pColorList( XColorList::CreateStdColorList() );
     126           0 :     long nCount = pColorList->Count();
     127           0 :     Color aColWhite( COL_WHITE );
     128           0 :     OUString aStrWhite( ModuleRes(STR_COLOR_WHITE) );
     129             : 
     130           0 :     if ( nCount > PALETTE_SIZE )
     131             :         // Show scrollbar if more than PALLETTE_SIZE colors are available
     132           0 :         m_aColorSet->SetStyle( m_aColorSet->GetStyle() | WB_VSCROLL );
     133             : 
     134           0 :     for ( i = 0; i < nCount; i++ )
     135             :     {
     136           0 :         XColorEntry* pEntry = pColorList->GetColor(i);
     137           0 :         m_aColorSet->InsertItem( i+1, pEntry->GetColor(), pEntry->GetName() );
     138             :     }
     139             : 
     140           0 :     while ( i < PALETTE_SIZE )
     141             :     {
     142             :         // fill empty elements if less then PALLETTE_SIZE colors are available
     143           0 :         m_aColorSet->InsertItem( i+1, aColWhite, aStrWhite );
     144           0 :         i++;
     145             :     }
     146             : 
     147           0 :     m_aColorSet->SetSelectHdl( LINK( this, OColorPopup, SelectHdl ) );
     148           0 :     m_aColorSet->SetColCount( PALETTE_X );
     149           0 :     m_aColorSet->SetLineCount( PALETTE_Y );
     150           0 :     Size aSize = m_aColorSet->CalcWindowSizePixel( aSize12 );
     151           0 :     aSize.Width()  += 4;
     152           0 :     aSize.Height() += 4;
     153           0 :     SetOutputSizePixel( aSize );
     154           0 :     m_aColorSet->Show();
     155           0 : }
     156             : 
     157           0 : OColorPopup::~OColorPopup()
     158             : {
     159           0 :     disposeOnce();
     160           0 : }
     161             : 
     162           0 : void OColorPopup::dispose()
     163             : {
     164           0 :     disposeBuilder();
     165           0 :     m_aColorSet.clear();
     166           0 :     m_pCondition.clear();
     167           0 :     FloatingWindow::dispose();
     168           0 : }
     169             : 
     170           0 : void OColorPopup::KeyInput( const KeyEvent& rKEvt )
     171             : {
     172           0 :     m_aColorSet->KeyInput(rKEvt);
     173           0 : }
     174             : 
     175           0 : void OColorPopup::Resize()
     176             : {
     177           0 :     Size aSize = GetOutputSizePixel();
     178           0 :     aSize.Width()  -= 4;
     179           0 :     aSize.Height() -= 4;
     180           0 :     m_aColorSet->SetPosSizePixel( Point(2,2), aSize );
     181           0 : }
     182             : 
     183           0 : void OColorPopup::StartSelection()
     184             : {
     185           0 :     m_aColorSet->StartSelection();
     186           0 : }
     187             : 
     188           0 : void OColorPopup::SetSlotId(sal_uInt16 _nSlotId)
     189             : {
     190           0 :     m_nSlotId = _nSlotId;
     191           0 :     if ( SID_ATTR_CHAR_COLOR_BACKGROUND == _nSlotId || SID_BACKGROUND_COLOR == _nSlotId )
     192             :     {
     193           0 :         m_aColorSet->SetStyle( m_aColorSet->GetStyle() | WB_NONEFIELD );
     194           0 :         m_aColorSet->SetText( OUString(ModuleRes( STR_TRANSPARENT )) );
     195             :     }
     196           0 : }
     197             : 
     198           0 : IMPL_LINK_NOARG(OColorPopup, SelectHdl)
     199             : {
     200           0 :     sal_uInt16 nItemId = m_aColorSet->GetSelectItemId();
     201           0 :     Color aColor( nItemId == 0 ? Color( COL_TRANSPARENT ) : m_aColorSet->GetItemColor( nItemId ) );
     202             : 
     203             :     /*  #i33380# Moved the following line above the Dispatch() calls.
     204             :         This instance may be deleted in the meantime (i.e. when a dialog is opened
     205             :         while in Dispatch()), accessing members will crash in this case. */
     206           0 :     m_aColorSet->SetNoSelection();
     207             : 
     208           0 :     if ( IsInPopupMode() )
     209           0 :         EndPopupMode();
     210             : 
     211           0 :     m_pCondition->ApplyCommand( m_nSlotId, aColor );
     212           0 :     return 0;
     213             : }
     214             : 
     215             : 
     216             : // = Condition
     217             : 
     218             : 
     219           0 : Condition::Condition( vcl::Window* _pParent, IConditionalFormatAction& _rAction, ::rptui::OReportController& _rController )
     220             :     :VclHBox(_pParent)
     221             :     ,m_rController( _rController )
     222             :     ,m_rAction( _rAction )
     223             :     ,m_pColorFloat(NULL)
     224             :     ,m_pBtnUpdaterFontColor(NULL)
     225             :     ,m_pBtnUpdaterBackgroundColor(NULL)
     226             :     ,m_nCondIndex( 0 )
     227           0 :     ,m_bInDestruction( false )
     228             : {
     229           0 :     m_pUIBuilder = new VclBuilder(this, getUIRootDir(), "modules/dbreport/ui/conditionwin.ui");
     230             : 
     231           0 :     get(m_pHeader, "headerLabel");
     232           0 :     get(m_pConditionType, "typeCombobox");
     233           0 :     get(m_pOperationList, "opCombobox");
     234           0 :     m_pCondLHS = new ConditionField(this, get<Edit>("lhsEntry"), get<PushButton>("lhsButton"));
     235           0 :     get(m_pOperandGlue, "andLabel");
     236           0 :     m_pCondRHS = new ConditionField(this, get<Edit>("rhsEntry"), get<PushButton>("rhsButton"));
     237           0 :     get(m_pActions, "formatToolbox");
     238           0 :     get(m_pPreview, "previewDrawingarea");
     239           0 :     get(m_pMoveUp, "upButton");
     240           0 :     get(m_pMoveDown, "downButton");
     241           0 :     get(m_pAddCondition, "addButton");
     242           0 :     get(m_pRemoveCondition, "removeButton");
     243             : 
     244           0 :     m_pActions->SetStyle(m_pActions->GetStyle()|WB_LINESPACING);
     245           0 :     m_pCondLHS->GrabFocus();
     246             : 
     247           0 :     m_pConditionType->SetSelectHdl( LINK( this, Condition, OnTypeSelected ) );
     248             : 
     249           0 :     m_pOperationList->SetDropDownLineCount( 10 );
     250           0 :     m_pOperationList->SetSelectHdl( LINK( this, Condition, OnOperationSelected ) );
     251             : 
     252           0 :     m_pActions->SetSelectHdl(LINK(this, Condition, OnFormatAction));
     253           0 :     m_pActions->SetDropdownClickHdl( LINK( this, Condition, DropdownClick ) );
     254           0 :     setToolBox(m_pActions);
     255             : 
     256           0 :     m_pMoveUp->SetClickHdl( LINK( this, Condition, OnConditionAction ) );
     257           0 :     m_pMoveDown->SetClickHdl( LINK( this, Condition, OnConditionAction ) );
     258           0 :     m_pAddCondition->SetClickHdl( LINK( this, Condition, OnConditionAction ) );
     259           0 :     m_pRemoveCondition->SetClickHdl( LINK( this, Condition, OnConditionAction ) );
     260             : 
     261           0 :     m_pMoveUp->SetStyle( m_pMoveUp->GetStyle() | WB_NOPOINTERFOCUS );
     262           0 :     m_pMoveDown->SetStyle( m_pMoveDown->GetStyle() | WB_NOPOINTERFOCUS );
     263           0 :     m_pAddCondition->SetStyle( m_pAddCondition->GetStyle() | WB_NOPOINTERFOCUS );
     264           0 :     m_pRemoveCondition->SetStyle( m_pRemoveCondition->GetStyle() | WB_NOPOINTERFOCUS );
     265             : 
     266           0 :     vcl::Font aFont( m_pAddCondition->GetFont() );
     267           0 :     aFont.SetWeight( WEIGHT_BOLD );
     268           0 :     m_pAddCondition->SetFont( aFont );
     269           0 :     m_pRemoveCondition->SetFont( aFont );
     270             : 
     271           0 :     m_pOperandGlue->SetStyle( m_pOperandGlue->GetStyle() | WB_VCENTER );
     272             : 
     273           0 :     m_pConditionType->SelectEntryPos( 0 );
     274           0 :     m_pOperationList->SelectEntryPos( 0 );
     275             : 
     276           0 :     m_nBoldId = m_pActions->GetItemId(".uno:Bold");
     277           0 :     m_nItalicId = m_pActions->GetItemId(".uno:Italic");
     278           0 :     m_nUnderLineId = m_pActions->GetItemId(".uno:Underline");
     279           0 :     m_nBackgroundColorId = m_pActions->GetItemId(".uno:BackgroundColor");
     280           0 :     m_nFontColorId = m_pActions->GetItemId(".uno:FontColor");
     281           0 :     m_nFontDialogId = m_pActions->GetItemId(".uno:FontDialog");
     282             : 
     283             :     m_pBtnUpdaterBackgroundColor = new svx::ToolboxButtonColorUpdater(
     284           0 :                                             SID_BACKGROUND_COLOR, m_nBackgroundColorId, m_pActions );
     285             :     m_pBtnUpdaterFontColor = new svx::ToolboxButtonColorUpdater(
     286           0 :                                             SID_ATTR_CHAR_COLOR2, m_nFontColorId, m_pActions );
     287             : 
     288           0 :     Show();
     289             : 
     290           0 :     ConditionalExpressionFactory::getKnownConditionalExpressions( m_aConditionalExpressions );
     291           0 : }
     292             : 
     293           0 : sal_uInt16 Condition::mapToolbarItemToSlotId(sal_uInt16 nItemId) const
     294             : {
     295           0 :     if (nItemId == m_nBoldId)
     296           0 :         return SID_ATTR_CHAR_WEIGHT;
     297           0 :     if (nItemId == m_nItalicId)
     298           0 :         return SID_ATTR_CHAR_POSTURE;
     299           0 :     if (nItemId == m_nUnderLineId)
     300           0 :         return SID_ATTR_CHAR_UNDERLINE;
     301           0 :     if (nItemId == m_nBackgroundColorId)
     302           0 :         return SID_BACKGROUND_COLOR;
     303           0 :     if (nItemId == m_nFontColorId)
     304           0 :         return SID_ATTR_CHAR_COLOR2;
     305           0 :     if (nItemId == m_nFontDialogId)
     306           0 :         return SID_CHAR_DLG;
     307           0 :     return 0;
     308             : }
     309             : 
     310           0 : Condition::~Condition()
     311             : {
     312           0 :     disposeOnce();
     313           0 : }
     314             : 
     315           0 : void Condition::dispose()
     316             : {
     317           0 :     m_bInDestruction = true;
     318             : 
     319           0 :     delete m_pBtnUpdaterFontColor;
     320           0 :     delete m_pCondLHS;
     321           0 :     delete m_pCondRHS;
     322           0 :     delete m_pBtnUpdaterBackgroundColor;
     323           0 :     m_pHeader.clear();
     324           0 :     m_pConditionType.clear();
     325           0 :     m_pOperationList.clear();
     326           0 :     m_pOperandGlue.clear();
     327           0 :     m_pActions.clear();
     328           0 :     m_pPreview.clear();
     329           0 :     m_pMoveUp.clear();
     330           0 :     m_pMoveDown.clear();
     331           0 :     m_pAddCondition.clear();
     332           0 :     m_pRemoveCondition.clear();
     333           0 :     m_pColorFloat.disposeAndClear();
     334           0 :     VclHBox::dispose();
     335           0 : }
     336             : 
     337           0 : IMPL_LINK_NOARG_TYPED( Condition, DropdownClick, ToolBox*, void )
     338             : {
     339           0 :     sal_uInt16 nId( m_pActions->GetCurItemId() );
     340           0 :     if ( !m_pColorFloat )
     341           0 :         m_pColorFloat = VclPtr<OColorPopup>::Create(m_pActions,this);
     342             : 
     343           0 :     sal_uInt16 nTextId = 0;
     344           0 :     if (nId == m_nFontColorId)
     345             :     {
     346           0 :         nTextId = STR_CHARCOLOR;
     347             :     }
     348           0 :     else if (nId == m_nBackgroundColorId)
     349             :     {
     350           0 :         nTextId = STR_CHARBACKGROUND;
     351             :     }
     352           0 :     if ( nTextId )
     353           0 :         m_pColorFloat->SetText(OUString(ModuleRes(nTextId)));
     354           0 :     m_pColorFloat->SetSlotId(mapToolbarItemToSlotId(nId));
     355           0 :     m_pColorFloat->SetPosPixel(m_pActions->GetItemPopupPosition(nId,m_pColorFloat->GetSizePixel()));
     356           0 :     m_pColorFloat->StartPopupMode(m_pActions);
     357           0 :     m_pColorFloat->StartSelection();
     358           0 : }
     359             : 
     360           0 : IMPL_LINK_NOARG_TYPED( Condition, OnFormatAction, ToolBox*, void )
     361             : {
     362           0 :     Color aCol(COL_AUTO);
     363           0 :     ApplyCommand(mapToolbarItemToSlotId(m_pActions->GetCurItemId()),aCol);
     364           0 : }
     365             : 
     366           0 : IMPL_LINK( Condition, OnConditionAction, Button*, _pClickedButton )
     367             : {
     368           0 :     if ( _pClickedButton == m_pMoveUp )
     369           0 :         m_rAction.moveConditionUp( getConditionIndex() );
     370           0 :     else if ( _pClickedButton == m_pMoveDown )
     371           0 :         m_rAction.moveConditionDown( getConditionIndex() );
     372           0 :     else if ( _pClickedButton == m_pAddCondition )
     373           0 :         m_rAction.addCondition( getConditionIndex() );
     374           0 :     else if ( _pClickedButton == m_pRemoveCondition )
     375           0 :         m_rAction.deleteCondition( getConditionIndex() );
     376           0 :     return 0L;
     377             : }
     378             : 
     379           0 : void Condition::ApplyCommand( sal_uInt16 _nCommandId, const ::Color& _rColor)
     380             : {
     381           0 :     if ( _nCommandId == SID_ATTR_CHAR_COLOR2 )
     382           0 :         m_pBtnUpdaterFontColor->Update( _rColor );
     383           0 :     else if ( _nCommandId == SID_BACKGROUND_COLOR )
     384           0 :         m_pBtnUpdaterBackgroundColor->Update( _rColor );
     385             : 
     386           0 :     m_rAction.applyCommand( m_nCondIndex, _nCommandId, _rColor );
     387           0 : }
     388             : 
     389           0 : void Condition::setImageList(sal_Int16 /*_eBitmapSet*/)
     390             : {
     391           0 : }
     392             : 
     393           0 : void Condition::resizeControls(const Size& /*_rDiff*/)
     394             : {
     395           0 : }
     396             : 
     397           0 : void Condition::GetFocus()
     398             : {
     399           0 :     VclHBox::GetFocus();
     400           0 :     if ( !m_bInDestruction )
     401           0 :         m_pCondLHS->GrabFocus();
     402           0 : }
     403             : 
     404           0 : IMPL_LINK( Condition, OnTypeSelected, ListBox*, /*_pNotInterestedIn*/ )
     405             : {
     406           0 :     impl_layoutOperands();
     407           0 :     return 0L;
     408             : }
     409             : 
     410             : 
     411           0 : IMPL_LINK( Condition, OnOperationSelected, ListBox*, /*_pNotInterestedIn*/ )
     412             : {
     413           0 :     impl_layoutOperands();
     414           0 :     return 0L;
     415             : }
     416             : 
     417           0 : void Condition::impl_layoutOperands()
     418             : {
     419           0 :     const ConditionType eType( impl_getCurrentConditionType() );
     420           0 :     const ComparisonOperation eOperation( impl_getCurrentComparisonOperation() );
     421             : 
     422           0 :     const bool bIsExpression = ( eType == eExpression );
     423             :     const bool bHaveRHS =
     424             :             (   ( eType == eFieldValueComparison )
     425           0 :             &&  (   ( eOperation == eBetween )
     426           0 :                 ||  ( eOperation == eNotBetween )
     427             :                 )
     428           0 :             );
     429             : 
     430             :     // the "condition type" list box
     431           0 :     m_pOperationList->Show( !bIsExpression );
     432           0 :     m_pOperandGlue->Show( bHaveRHS );
     433           0 :     m_pCondRHS->Show( bHaveRHS );
     434           0 : }
     435             : 
     436           0 : void Condition::impl_setCondition( const OUString& _rConditionFormula )
     437             : {
     438             :     // determine the condition's type and comparison operation
     439           0 :     ConditionType eType( eFieldValueComparison );
     440           0 :     ComparisonOperation eOperation( eBetween );
     441             : 
     442             :     // LHS and RHS, matched below
     443           0 :     OUString sLHS, sRHS;
     444             : 
     445           0 :     if ( !_rConditionFormula.isEmpty() )
     446             :     {
     447             :         // the unprefixed expression which forms the condition
     448           0 :         ReportFormula aFormula( _rConditionFormula );
     449             :         OSL_ENSURE( aFormula.getType() == ReportFormula::Expression, "Condition::setCondition: illegal formula!" );
     450           0 :         OUString sExpression;
     451           0 :         if ( aFormula.getType() == ReportFormula::Expression )
     452           0 :             sExpression = aFormula.getExpression();
     453             :         // as fallback, if the below matching does not succeed, assume
     454             :         // the whole expression is the LHS
     455           0 :         eType = eExpression;
     456           0 :         sLHS = sExpression;
     457             : 
     458             :         // the data field (or expression) to which our control is bound
     459           0 :         const ReportFormula aFieldContentFormula( m_rAction.getDataField() );
     460           0 :         const OUString sUnprefixedFieldContent( aFieldContentFormula.getBracketedFieldOrExpression() );
     461             : 
     462             :         // check whether one of the Field Value Expression Factories recognizes the expression
     463           0 :         for (   ConditionalExpressions::const_iterator exp = m_aConditionalExpressions.begin();
     464           0 :                 exp != m_aConditionalExpressions.end();
     465             :                 ++exp
     466             :             )
     467             :         {
     468           0 :             if ( exp->second->matchExpression( sExpression, sUnprefixedFieldContent, sLHS, sRHS ) )
     469             :             {
     470           0 :                 eType = eFieldValueComparison;
     471           0 :                 eOperation = exp->first;
     472           0 :                 break;
     473             :             }
     474           0 :         }
     475             :     }
     476             : 
     477             :     // update UI
     478           0 :     m_pConditionType->SelectEntryPos( (sal_uInt16)eType );
     479           0 :     m_pOperationList->SelectEntryPos( (sal_uInt16)eOperation );
     480           0 :     m_pCondLHS->SetText( sLHS );
     481           0 :     m_pCondRHS->SetText( sRHS );
     482             : 
     483             :     // re-layout
     484           0 :     impl_layoutOperands();
     485           0 : }
     486             : 
     487             : 
     488           0 : void Condition::setCondition( const uno::Reference< report::XFormatCondition >& _rxCondition )
     489             : {
     490             :     OSL_PRECOND( _rxCondition.is(), "Condition::setCondition: empty condition object!" );
     491           0 :     if ( !_rxCondition.is() )
     492           0 :         return;
     493             : 
     494           0 :     OUString sConditionFormula;
     495             :     try
     496             :     {
     497           0 :         if ( _rxCondition.is() )
     498           0 :             sConditionFormula =  _rxCondition->getFormula();
     499             :     }
     500           0 :     catch( const Exception& )
     501             :     {
     502             :         DBG_UNHANDLED_EXCEPTION();
     503             :     }
     504           0 :     impl_setCondition( sConditionFormula );
     505           0 :     updateToolbar( _rxCondition.get() );
     506             : }
     507             : 
     508             : 
     509           0 : void Condition::updateToolbar(const uno::Reference< report::XReportControlFormat >& _xReportControlFormat)
     510             : {
     511             :     OSL_ENSURE(_xReportControlFormat.is(),"XReportControlFormat is NULL!");
     512           0 :     if ( _xReportControlFormat.is() )
     513             :     {
     514           0 :         sal_uInt16 nItemCount = m_pActions->GetItemCount();
     515           0 :         for (sal_uInt16 j = 0; j< nItemCount; ++j)
     516             :         {
     517           0 :             sal_uInt16 nItemId = m_pActions->GetItemId(j);
     518           0 :             m_pActions->CheckItem( nItemId, OReportController::isFormatCommandEnabled(mapToolbarItemToSlotId(nItemId),
     519           0 :                 _xReportControlFormat ) );
     520             :         }
     521             : 
     522             :         try
     523             :         {
     524           0 :             vcl::Font aBaseFont( Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont() );
     525           0 :             SvxFont aFont( VCLUnoHelper::CreateFont( _xReportControlFormat->getFontDescriptor(), aBaseFont ) );
     526           0 :             aFont.SetHeight( OutputDevice::LogicToLogic( Size( 0, (sal_Int32)aFont.GetHeight() ), MAP_POINT, MAP_TWIP ).Height());
     527           0 :             aFont.SetEmphasisMark( static_cast< FontEmphasisMark >( _xReportControlFormat->getControlTextEmphasis() ) );
     528           0 :             aFont.SetRelief( static_cast< FontRelief >( _xReportControlFormat->getCharRelief() ) );
     529           0 :             aFont.SetColor( _xReportControlFormat->getCharColor() );
     530           0 :             m_pPreview->SetFont( aFont, aFont, aFont );
     531           0 :             m_pPreview->SetBackColor( _xReportControlFormat->getControlBackground() );
     532           0 :             m_pPreview->SetTextLineColor( Color( _xReportControlFormat->getCharUnderlineColor() ) );
     533             :         }
     534           0 :         catch( const Exception& )
     535             :         {
     536             :             DBG_UNHANDLED_EXCEPTION();
     537             :         }
     538             :     }
     539           0 : }
     540             : 
     541           0 : void Condition::fillFormatCondition(const uno::Reference< report::XFormatCondition >& _xCondition)
     542             : {
     543           0 :     const ConditionType eType( impl_getCurrentConditionType() );
     544           0 :     const ComparisonOperation eOperation( impl_getCurrentComparisonOperation() );
     545             : 
     546           0 :     const OUString sLHS( m_pCondLHS->GetText() );
     547           0 :     const OUString sRHS( m_pCondRHS->GetText() );
     548             : 
     549           0 :     OUString sUndecoratedFormula( sLHS );
     550             : 
     551           0 :     if ( eType == eFieldValueComparison )
     552             :     {
     553           0 :         ReportFormula aFieldContentFormula( m_rAction.getDataField() );
     554           0 :         OUString sUnprefixedFieldContent( aFieldContentFormula.getBracketedFieldOrExpression() );
     555             : 
     556           0 :         PConditionalExpression pFactory( m_aConditionalExpressions[ eOperation ] );
     557           0 :         sUndecoratedFormula = pFactory->assembleExpression( sUnprefixedFieldContent, sLHS, sRHS );
     558             :     }
     559             : 
     560           0 :     ReportFormula aFormula( ReportFormula::Expression, sUndecoratedFormula );
     561           0 :     _xCondition->setFormula( aFormula.getCompleteFormula() );
     562           0 : }
     563             : 
     564           0 : void Condition::setConditionIndex( size_t _nCondIndex, size_t _nCondCount )
     565             : {
     566           0 :     m_nCondIndex = _nCondIndex;
     567           0 :     OUString sHeader( ModuleRes( STR_NUMBERED_CONDITION ) );
     568           0 :     sHeader = sHeader.replaceFirst( "$number$", OUString::number( _nCondIndex + 1) );
     569           0 :     m_pHeader->SetText( sHeader );
     570             : 
     571           0 :     m_pMoveUp->Enable( _nCondIndex > 0 );
     572             :     OSL_PRECOND( _nCondCount > 0, "Condition::setConditionIndex: having no conditions at all is nonsense!" );
     573           0 :     m_pMoveDown->Enable( _nCondIndex < _nCondCount - 1 );
     574           0 : }
     575             : 
     576             : 
     577           0 : bool Condition::isEmpty() const
     578             : {
     579           0 :     return m_pCondLHS->GetText().isEmpty();
     580             : }
     581             : 
     582             : 
     583           3 : } // rptui
     584             : 
     585             : 
     586             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11