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

Generated by: LCOV version 1.10