19e0e4191SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 39e0e4191SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 49e0e4191SAndrew Rist * or more contributor license agreements. See the NOTICE file 59e0e4191SAndrew Rist * distributed with this work for additional information 69e0e4191SAndrew Rist * regarding copyright ownership. The ASF licenses this file 79e0e4191SAndrew Rist * to you under the Apache License, Version 2.0 (the 89e0e4191SAndrew Rist * "License"); you may not use this file except in compliance 99e0e4191SAndrew Rist * with the License. You may obtain a copy of the License at 109e0e4191SAndrew Rist * 119e0e4191SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 129e0e4191SAndrew Rist * 139e0e4191SAndrew Rist * Unless required by applicable law or agreed to in writing, 149e0e4191SAndrew Rist * software distributed under the License is distributed on an 159e0e4191SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169e0e4191SAndrew Rist * KIND, either express or implied. See the License for the 179e0e4191SAndrew Rist * specific language governing permissions and limitations 189e0e4191SAndrew Rist * under the License. 199e0e4191SAndrew Rist * 209e0e4191SAndrew Rist *************************************************************/ 219e0e4191SAndrew Rist 229e0e4191SAndrew Rist 23cdf0e10cSrcweir #include "precompiled_reportdesign.hxx" 24cdf0e10cSrcweir 25cdf0e10cSrcweir #include "Condition.hxx" 26cdf0e10cSrcweir #include "UITools.hxx" 27cdf0e10cSrcweir #include "CondFormat.hxx" 28cdf0e10cSrcweir #include "CondFormat.hrc" 29cdf0e10cSrcweir #include "RptResId.hrc" 30cdf0e10cSrcweir #include "ReportController.hxx" 31cdf0e10cSrcweir #include "ModuleHelper.hxx" 32cdf0e10cSrcweir #include "ColorChanger.hxx" 33cdf0e10cSrcweir #include "RptResId.hrc" 34cdf0e10cSrcweir #include "helpids.hrc" 35cdf0e10cSrcweir #include "reportformula.hxx" 36cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp> 37cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 38cdf0e10cSrcweir #include <com/sun/star/ui/XUIConfigurationManager.hpp> 39cdf0e10cSrcweir #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp> 40cdf0e10cSrcweir #include <com/sun/star/ui/XImageManager.hpp> 41cdf0e10cSrcweir #include <com/sun/star/awt/FontDescriptor.hpp> 42cdf0e10cSrcweir #include <com/sun/star/ui/ImageType.hpp> 43cdf0e10cSrcweir 44cdf0e10cSrcweir #define ITEMID_COLOR 45cdf0e10cSrcweir #define ITEMID_BRUSH 46cdf0e10cSrcweir #include <svx/tbcontrl.hxx> 47cdf0e10cSrcweir #include <svx/svxids.hrc> 48cdf0e10cSrcweir #include <svx/xtable.hxx> 49cdf0e10cSrcweir #include <svx/tbxcolorupdate.hxx> 50cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 51cdf0e10cSrcweir #include <svtools/imgdef.hxx> 52cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 53cdf0e10cSrcweir #include <vcl/svapp.hxx> 54cdf0e10cSrcweir #include <vcl/bmpacc.hxx> 55cdf0e10cSrcweir #include <tools/diagnose_ex.h> 56cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 57cdf0e10cSrcweir 58cdf0e10cSrcweir namespace rptui 59cdf0e10cSrcweir { 60cdf0e10cSrcweir using namespace ::com::sun::star; 61cdf0e10cSrcweir using namespace ::com::sun::star::uno; 62cdf0e10cSrcweir using namespace ::com::sun::star::beans; 63cdf0e10cSrcweir 64cdf0e10cSrcweir ConditionField::ConditionField( Condition* _pParent, const ResId& _rResId ) : Edit(_pParent,_rResId) 65cdf0e10cSrcweir ,m_pParent(_pParent) 66cdf0e10cSrcweir ,m_aFormula(this) 67cdf0e10cSrcweir { 68cdf0e10cSrcweir m_pSubEdit = new Edit(this,0); 69cdf0e10cSrcweir SetSubEdit(m_pSubEdit); 70cdf0e10cSrcweir m_pSubEdit->EnableRTL( sal_False ); 71cdf0e10cSrcweir m_pSubEdit->SetPosPixel( Point() ); 72cdf0e10cSrcweir 73cdf0e10cSrcweir m_aFormula.SetText(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("..."))); 74cdf0e10cSrcweir m_aFormula.SetClickHdl( LINK( this, ConditionField, OnFormula ) ); 75cdf0e10cSrcweir m_aFormula.Show(); 76cdf0e10cSrcweir m_pSubEdit->Show(); 77cdf0e10cSrcweir Resize(); 78cdf0e10cSrcweir } 79cdf0e10cSrcweir // ----------------------------------------------------------------------------- 80cdf0e10cSrcweir ConditionField::~ConditionField() 81cdf0e10cSrcweir { 82cdf0e10cSrcweir SetSubEdit(NULL); 83cdf0e10cSrcweir delete m_pSubEdit; 84cdf0e10cSrcweir } 85cdf0e10cSrcweir // ----------------------------------------------------------------------------- 86cdf0e10cSrcweir void ConditionField::Resize() 87cdf0e10cSrcweir { 88cdf0e10cSrcweir Edit::Resize(); 89cdf0e10cSrcweir const Size aSize = GetOutputSizePixel(); 90cdf0e10cSrcweir const Size aButtonSize( LogicToPixel( Size( 12, 0 ), MAP_APPFONT ).Width(),aSize.Height()); 91cdf0e10cSrcweir const Point aButtonPos(aSize.Width() - aButtonSize.Width(), 0); 92cdf0e10cSrcweir m_aFormula.SetPosSizePixel(aButtonPos,aButtonSize); 93cdf0e10cSrcweir m_pSubEdit->SetPosSizePixel(Point(0,0),Size(aButtonPos.X() ,aSize.Height())); 94cdf0e10cSrcweir } 95cdf0e10cSrcweir // ----------------------------------------------------------------------------- 96cdf0e10cSrcweir IMPL_LINK( ConditionField, OnFormula, Button*, /*_pClickedButton*/ ) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir ::rtl::OUString sFormula(m_pSubEdit->GetText()); 99cdf0e10cSrcweir const sal_Int32 nLen = sFormula.getLength(); 100cdf0e10cSrcweir if ( nLen ) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir ReportFormula aFormula( sFormula ); 103cdf0e10cSrcweir sFormula = aFormula.getCompleteFormula(); 104cdf0e10cSrcweir } // if ( nLen ) 105cdf0e10cSrcweir uno::Reference< awt::XWindow> xInspectorWindow = VCLUnoHelper::GetInterface(this); 106cdf0e10cSrcweir uno::Reference< beans::XPropertySet> xProp(m_pParent->getController().getRowSet(),uno::UNO_QUERY); 107cdf0e10cSrcweir if ( rptui::openDialogFormula_nothrow( sFormula, m_pParent->getController().getContext(),xInspectorWindow,xProp ) ) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir ReportFormula aFormula( sFormula ); 110cdf0e10cSrcweir m_pSubEdit->SetText(aFormula.getUndecoratedContent()); 111cdf0e10cSrcweir } 112cdf0e10cSrcweir return 0L; 113cdf0e10cSrcweir } 114cdf0e10cSrcweir //======================================================================== 115cdf0e10cSrcweir // class SvxColorWindow_Impl -------------------------------------------------- 116cdf0e10cSrcweir //======================================================================== 117cdf0e10cSrcweir #ifndef WB_NO_DIRECTSELECT 118cdf0e10cSrcweir #define WB_NO_DIRECTSELECT ((WinBits)0x04000000) 119cdf0e10cSrcweir #endif 120cdf0e10cSrcweir 121cdf0e10cSrcweir #define PALETTE_X 10 122cdf0e10cSrcweir #define PALETTE_Y 10 123cdf0e10cSrcweir #define PALETTE_SIZE (PALETTE_X * PALETTE_Y) 124cdf0e10cSrcweir class OColorPopup : public FloatingWindow 125cdf0e10cSrcweir { 126cdf0e10cSrcweir DECL_LINK( SelectHdl, void * ); 127cdf0e10cSrcweir Condition* m_pCondition; 128cdf0e10cSrcweir sal_uInt16 m_nSlotId; 129cdf0e10cSrcweir public: 130cdf0e10cSrcweir OColorPopup(Window* _pParent,Condition* _pCondition); 131cdf0e10cSrcweir ValueSet m_aColorSet; 132cdf0e10cSrcweir 133cdf0e10cSrcweir virtual void KeyInput( const KeyEvent& rKEvt ); 134cdf0e10cSrcweir virtual void Resize(); 135cdf0e10cSrcweir 136cdf0e10cSrcweir void StartSelection(); 137cdf0e10cSrcweir void SetSlotId(sal_uInt16 _nSlotId); 138cdf0e10cSrcweir }; 139cdf0e10cSrcweir // ----------------------------------------------------------------------------- 140cdf0e10cSrcweir OColorPopup::OColorPopup(Window* _pParent,Condition* _pCondition) 141cdf0e10cSrcweir :FloatingWindow(_pParent, WinBits( WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK|WB_DIALOGCONTROL )) 142cdf0e10cSrcweir ,m_pCondition(_pCondition) 143cdf0e10cSrcweir ,m_nSlotId(0) 144cdf0e10cSrcweir ,m_aColorSet( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir m_aColorSet.SetHelpId( HID_RPT_POPUP_COLOR_CTRL ); 147cdf0e10cSrcweir SetHelpId( HID_RPT_POPUP_COLOR ); 148cdf0e10cSrcweir const Size aSize12( 13, 13 ); 149*c7be74b1SArmin Le Grand XColorListSharedPtr aColorTable(XPropertyListFactory::CreateSharedXColorList(SvtPathOptions().GetPalettePath())); 150cdf0e10cSrcweir short i = 0; 151*c7be74b1SArmin Le Grand long nCount = aColorTable.get() ? aColorTable->Count() : 0; 152cdf0e10cSrcweir XColorEntry* pEntry = NULL; 153cdf0e10cSrcweir Color aColWhite( COL_WHITE ); 154cdf0e10cSrcweir String aStrWhite( ModuleRes(STR_COLOR_WHITE) ); 155cdf0e10cSrcweir 156cdf0e10cSrcweir if ( nCount > PALETTE_SIZE ) 157cdf0e10cSrcweir // Show scrollbar if more than PALLETTE_SIZE colors are available 158cdf0e10cSrcweir m_aColorSet.SetStyle( m_aColorSet.GetStyle() | WB_VSCROLL ); 159cdf0e10cSrcweir 160cdf0e10cSrcweir for ( i = 0; i < nCount; i++ ) 161cdf0e10cSrcweir { 162*c7be74b1SArmin Le Grand pEntry = aColorTable->GetColor(i); 163cdf0e10cSrcweir m_aColorSet.InsertItem( i+1, pEntry->GetColor(), pEntry->GetName() ); 164cdf0e10cSrcweir } 165cdf0e10cSrcweir 166cdf0e10cSrcweir while ( i < PALETTE_SIZE ) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir // fill empty elements if less then PALLETTE_SIZE colors are available 169cdf0e10cSrcweir m_aColorSet.InsertItem( i+1, aColWhite, aStrWhite ); 170cdf0e10cSrcweir i++; 171cdf0e10cSrcweir } 172cdf0e10cSrcweir 173cdf0e10cSrcweir m_aColorSet.SetSelectHdl( LINK( this, OColorPopup, SelectHdl ) ); 174cdf0e10cSrcweir m_aColorSet.SetColCount( PALETTE_X ); 175cdf0e10cSrcweir m_aColorSet.SetLineCount( PALETTE_Y ); 176cdf0e10cSrcweir Size aSize = m_aColorSet.CalcWindowSizePixel( aSize12 ); 177cdf0e10cSrcweir aSize.Width() += 4; 178cdf0e10cSrcweir aSize.Height() += 4; 179cdf0e10cSrcweir SetOutputSizePixel( aSize ); 180cdf0e10cSrcweir m_aColorSet.Show(); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir // ----------------------------------------------------------------------------- 183cdf0e10cSrcweir void OColorPopup::KeyInput( const KeyEvent& rKEvt ) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir m_aColorSet.KeyInput(rKEvt); 186cdf0e10cSrcweir } 187cdf0e10cSrcweir 188cdf0e10cSrcweir // ----------------------------------------------------------------------------- 189cdf0e10cSrcweir void OColorPopup::Resize() 190cdf0e10cSrcweir { 191cdf0e10cSrcweir Size aSize = GetOutputSizePixel(); 192cdf0e10cSrcweir aSize.Width() -= 4; 193cdf0e10cSrcweir aSize.Height() -= 4; 194cdf0e10cSrcweir m_aColorSet.SetPosSizePixel( Point(2,2), aSize ); 195cdf0e10cSrcweir } 196cdf0e10cSrcweir 197cdf0e10cSrcweir // ----------------------------------------------------------------------------- 198cdf0e10cSrcweir void OColorPopup::StartSelection() 199cdf0e10cSrcweir { 200cdf0e10cSrcweir m_aColorSet.StartSelection(); 201cdf0e10cSrcweir } 202cdf0e10cSrcweir // ----------------------------------------------------------------------------- 203cdf0e10cSrcweir void OColorPopup::SetSlotId(sal_uInt16 _nSlotId) 204cdf0e10cSrcweir { 205cdf0e10cSrcweir m_nSlotId = _nSlotId; 206cdf0e10cSrcweir if ( SID_ATTR_CHAR_COLOR_BACKGROUND == _nSlotId || SID_BACKGROUND_COLOR == _nSlotId ) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir m_aColorSet.SetStyle( m_aColorSet.GetStyle() | WB_NONEFIELD ); 209cdf0e10cSrcweir m_aColorSet.SetText( String(ModuleRes( STR_TRANSPARENT )) ); 210cdf0e10cSrcweir } // if ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId ) 211cdf0e10cSrcweir } 212cdf0e10cSrcweir // ----------------------------------------------------------------------------- 213cdf0e10cSrcweir IMPL_LINK( OColorPopup, SelectHdl, void *, EMPTYARG ) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir sal_uInt16 nItemId = m_aColorSet.GetSelectItemId(); 216cdf0e10cSrcweir Color aColor( nItemId == 0 ? Color( COL_TRANSPARENT ) : m_aColorSet.GetItemColor( nItemId ) ); 217cdf0e10cSrcweir 218cdf0e10cSrcweir /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() calls. 219cdf0e10cSrcweir This instance may be deleted in the meantime (i.e. when a dialog is opened 220cdf0e10cSrcweir while in Dispatch()), accessing members will crash in this case. */ 221cdf0e10cSrcweir m_aColorSet.SetNoSelection(); 222cdf0e10cSrcweir 223cdf0e10cSrcweir if ( IsInPopupMode() ) 224cdf0e10cSrcweir EndPopupMode(); 225cdf0e10cSrcweir 226cdf0e10cSrcweir m_pCondition->ApplyCommand( m_nSlotId, aColor ); 227cdf0e10cSrcweir return 0; 228cdf0e10cSrcweir } 229cdf0e10cSrcweir 230cdf0e10cSrcweir // ============================================================================= 231cdf0e10cSrcweir // = Condition 232cdf0e10cSrcweir // ============================================================================= 233cdf0e10cSrcweir // ----------------------------------------------------------------------------- 234cdf0e10cSrcweir Condition::Condition( Window* _pParent, IConditionalFormatAction& _rAction, ::rptui::OReportController& _rController ) 235cdf0e10cSrcweir :Control(_pParent, ModuleRes(WIN_CONDITION)) 236cdf0e10cSrcweir ,m_rController( _rController ) 237cdf0e10cSrcweir ,m_rAction( _rAction ) 238cdf0e10cSrcweir ,m_aHeader(this, ModuleRes(FL_CONDITION_HEADER)) 239cdf0e10cSrcweir ,m_aConditionType(this, ModuleRes(LB_COND_TYPE)) 240cdf0e10cSrcweir ,m_aOperationList( this, ModuleRes(LB_OP)) 241cdf0e10cSrcweir ,m_aCondLHS(this, ModuleRes(ED_CONDITION_LHS)) 242cdf0e10cSrcweir ,m_aOperandGlue(this, ModuleRes(FT_AND)) 243cdf0e10cSrcweir ,m_aCondRHS(this, ModuleRes(ED_CONDITION_RHS)) 244cdf0e10cSrcweir ,m_aActions(this, ModuleRes(TB_FORMAT)) 245cdf0e10cSrcweir ,m_aPreview(this, ModuleRes(CRTL_FORMAT_PREVIEW)) 246cdf0e10cSrcweir ,m_aMoveUp( this, ModuleRes( BTN_MOVE_UP ) ) 247cdf0e10cSrcweir ,m_aMoveDown( this, ModuleRes( BTN_MOVE_DOWN ) ) 248cdf0e10cSrcweir ,m_aAddCondition( this, ModuleRes( BTN_ADD_CONDITION ) ) 249cdf0e10cSrcweir ,m_aRemoveCondition( this, ModuleRes( BTN_REMOVE_CONDITION ) ) 250cdf0e10cSrcweir ,m_pColorFloat(NULL) 251cdf0e10cSrcweir ,m_pBtnUpdaterFontColor(NULL) 252cdf0e10cSrcweir ,m_pBtnUpdaterBackgroundColor(NULL) 253cdf0e10cSrcweir ,m_nCondIndex( 0 ) 254cdf0e10cSrcweir ,m_nLastKnownWindowWidth( -1 ) 255cdf0e10cSrcweir ,m_bInDestruction( false ) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir m_aMoveUp.SetModeImage( ModuleRes( IMG_MOVE_UP_HC ), BMP_COLOR_HIGHCONTRAST ); 258cdf0e10cSrcweir m_aMoveDown.SetModeImage( ModuleRes( IMG_MOVE_DOWN_HC ), BMP_COLOR_HIGHCONTRAST ); 259cdf0e10cSrcweir 260cdf0e10cSrcweir FreeResource(); 261cdf0e10cSrcweir m_aActions.SetStyle(m_aActions.GetStyle()|WB_LINESPACING); 262cdf0e10cSrcweir m_aCondLHS.GrabFocus(); 263cdf0e10cSrcweir 264cdf0e10cSrcweir m_aConditionType.SetSelectHdl( LINK( this, Condition, OnTypeSelected ) ); 265cdf0e10cSrcweir 266cdf0e10cSrcweir m_aOperationList.SetDropDownLineCount( 10 ); 267cdf0e10cSrcweir m_aOperationList.SetSelectHdl( LINK( this, Condition, OnOperationSelected ) ); 268cdf0e10cSrcweir 269cdf0e10cSrcweir m_aActions.SetSelectHdl(LINK(this, Condition, OnFormatAction)); 270cdf0e10cSrcweir m_aActions.SetDropdownClickHdl( LINK( this, Condition, DropdownClick ) ); 271cdf0e10cSrcweir setToolBox(&m_aActions); 272cdf0e10cSrcweir 273cdf0e10cSrcweir m_aMoveUp.SetClickHdl( LINK( this, Condition, OnConditionAction ) ); 274cdf0e10cSrcweir m_aMoveDown.SetClickHdl( LINK( this, Condition, OnConditionAction ) ); 275cdf0e10cSrcweir m_aAddCondition.SetClickHdl( LINK( this, Condition, OnConditionAction ) ); 276cdf0e10cSrcweir m_aRemoveCondition.SetClickHdl( LINK( this, Condition, OnConditionAction ) ); 277cdf0e10cSrcweir 278cdf0e10cSrcweir m_aMoveUp.SetStyle( m_aMoveUp.GetStyle() | WB_NOPOINTERFOCUS ); 279cdf0e10cSrcweir m_aMoveDown.SetStyle( m_aMoveDown.GetStyle() | WB_NOPOINTERFOCUS ); 280cdf0e10cSrcweir m_aAddCondition.SetStyle( m_aMoveUp.GetStyle() | WB_NOPOINTERFOCUS | WB_CENTER | WB_VCENTER ); 281cdf0e10cSrcweir m_aRemoveCondition.SetStyle( m_aMoveDown.GetStyle() | WB_NOPOINTERFOCUS | WB_CENTER | WB_VCENTER ); 282cdf0e10cSrcweir 283cdf0e10cSrcweir Font aFont( m_aAddCondition.GetFont() ); 284cdf0e10cSrcweir aFont.SetWeight( WEIGHT_BOLD ); 285cdf0e10cSrcweir m_aAddCondition.SetFont( aFont ); 286cdf0e10cSrcweir m_aRemoveCondition.SetFont( aFont ); 287cdf0e10cSrcweir 288cdf0e10cSrcweir m_aOperandGlue.SetStyle( m_aOperandGlue.GetStyle() | WB_VCENTER ); 289cdf0e10cSrcweir 290cdf0e10cSrcweir m_aConditionType.SelectEntryPos( 0 ); 291cdf0e10cSrcweir m_aOperationList.SelectEntryPos( 0 ); 292cdf0e10cSrcweir 293cdf0e10cSrcweir // the toolbar got its site automatically, ensure that the preview is positioned 294cdf0e10cSrcweir // right of it 295cdf0e10cSrcweir Size aRelatedControls( LogicToPixel( Size( RELATED_CONTROLS, 0 ), MAP_APPFONT ) ); 296cdf0e10cSrcweir Point aToolbarPos( m_aActions.GetPosPixel() ); 297cdf0e10cSrcweir Size aToolbarSize( m_aActions.GetSizePixel() ); 298cdf0e10cSrcweir m_aPreview.SetPosSizePixel( aToolbarPos.X() + aToolbarSize.Width() + 2 * aRelatedControls.Width(), 299cdf0e10cSrcweir 0, 0, 0, WINDOW_POSSIZE_X ); 300cdf0e10cSrcweir 301cdf0e10cSrcweir // ensure the toolbar is vertically centered, relative to the preview 302cdf0e10cSrcweir Size aPreviewSize( m_aPreview.GetSizePixel() ); 303cdf0e10cSrcweir m_aActions.SetPosSizePixel( 0, aToolbarPos.Y() + ( aPreviewSize.Height() - aToolbarSize.Height() ) / 2, 0, 0, WINDOW_POSSIZE_Y ); 304cdf0e10cSrcweir 305cdf0e10cSrcweir m_pBtnUpdaterBackgroundColor = new ::svx::ToolboxButtonColorUpdater( 306cdf0e10cSrcweir SID_BACKGROUND_COLOR, SID_BACKGROUND_COLOR, &m_aActions ); 307cdf0e10cSrcweir m_pBtnUpdaterFontColor = new ::svx::ToolboxButtonColorUpdater( 308cdf0e10cSrcweir SID_ATTR_CHAR_COLOR2, SID_ATTR_CHAR_COLOR2, &m_aActions, TBX_UPDATER_MODE_CHAR_COLOR_NEW ); 309cdf0e10cSrcweir 310cdf0e10cSrcweir Show(); 311cdf0e10cSrcweir 312cdf0e10cSrcweir impl_layoutAll(); 313cdf0e10cSrcweir 314cdf0e10cSrcweir ConditionalExpressionFactory::getKnownConditionalExpressions( m_aConditionalExpressions ); 315cdf0e10cSrcweir } 316cdf0e10cSrcweir 317cdf0e10cSrcweir // ----------------------------------------------------------------------------- 318cdf0e10cSrcweir Condition::~Condition() 319cdf0e10cSrcweir { 320cdf0e10cSrcweir m_bInDestruction = true; 321cdf0e10cSrcweir 322cdf0e10cSrcweir delete m_pColorFloat; 323cdf0e10cSrcweir delete m_pBtnUpdaterFontColor; 324cdf0e10cSrcweir delete m_pBtnUpdaterBackgroundColor; 325cdf0e10cSrcweir } 326cdf0e10cSrcweir // ----------------------------------------------------------------------------- 327cdf0e10cSrcweir IMPL_LINK( Condition, DropdownClick, ToolBox*, /*pToolBar*/ ) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir sal_uInt16 nId( m_aActions.GetCurItemId() ); 330cdf0e10cSrcweir if ( !m_pColorFloat ) 331cdf0e10cSrcweir m_pColorFloat = new OColorPopup(&m_aActions,this); 332cdf0e10cSrcweir 333cdf0e10cSrcweir sal_uInt16 nTextId = 0; 334cdf0e10cSrcweir switch(nId) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir case SID_ATTR_CHAR_COLOR2: 337cdf0e10cSrcweir nTextId = STR_CHARCOLOR; 338cdf0e10cSrcweir break; 339cdf0e10cSrcweir case SID_BACKGROUND_COLOR: 340cdf0e10cSrcweir nTextId = STR_CHARBACKGROUND; 341cdf0e10cSrcweir break; 342cdf0e10cSrcweir default: 343cdf0e10cSrcweir break; 344cdf0e10cSrcweir } // switch(nId) 345cdf0e10cSrcweir if ( nTextId ) 346cdf0e10cSrcweir m_pColorFloat->SetText(String(ModuleRes(nTextId))); 347cdf0e10cSrcweir m_pColorFloat->SetSlotId(nId); 348cdf0e10cSrcweir m_pColorFloat->SetPosPixel(m_aActions.GetItemPopupPosition(nId,m_pColorFloat->GetSizePixel())); 349cdf0e10cSrcweir m_pColorFloat->StartPopupMode(&m_aActions); 350cdf0e10cSrcweir m_pColorFloat->StartSelection(); 351cdf0e10cSrcweir 352cdf0e10cSrcweir return 1; 353cdf0e10cSrcweir } 354cdf0e10cSrcweir //------------------------------------------------------------------ 355cdf0e10cSrcweir IMPL_LINK( Condition, OnFormatAction, ToolBox*, /*NOTINTERESTEDIN*/ ) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir Color aCol(COL_AUTO); 358cdf0e10cSrcweir ApplyCommand(m_aActions.GetCurItemId(),aCol); 359cdf0e10cSrcweir return 0L; 360cdf0e10cSrcweir } 361cdf0e10cSrcweir 362cdf0e10cSrcweir //------------------------------------------------------------------ 363cdf0e10cSrcweir IMPL_LINK( Condition, OnConditionAction, Button*, _pClickedButton ) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir if ( _pClickedButton == &m_aMoveUp ) 366cdf0e10cSrcweir m_rAction.moveConditionUp( getConditionIndex() ); 367cdf0e10cSrcweir else if ( _pClickedButton == &m_aMoveDown ) 368cdf0e10cSrcweir m_rAction.moveConditionDown( getConditionIndex() ); 369cdf0e10cSrcweir else if ( _pClickedButton == &m_aAddCondition ) 370cdf0e10cSrcweir m_rAction.addCondition( getConditionIndex() ); 371cdf0e10cSrcweir else if ( _pClickedButton == &m_aRemoveCondition ) 372cdf0e10cSrcweir m_rAction.deleteCondition( getConditionIndex() ); 373cdf0e10cSrcweir return 0L; 374cdf0e10cSrcweir } 375cdf0e10cSrcweir 376cdf0e10cSrcweir //------------------------------------------------------------------------------ 377cdf0e10cSrcweir void Condition::ApplyCommand( sal_uInt16 _nCommandId, const ::Color& _rColor) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir if ( _nCommandId == SID_ATTR_CHAR_COLOR2 ) 380cdf0e10cSrcweir m_pBtnUpdaterFontColor->Update( _rColor ); 381cdf0e10cSrcweir else if ( _nCommandId == SID_BACKGROUND_COLOR ) 382cdf0e10cSrcweir m_pBtnUpdaterBackgroundColor->Update( _rColor ); 383cdf0e10cSrcweir 384cdf0e10cSrcweir m_rAction.applyCommand( m_nCondIndex, _nCommandId, _rColor ); 385cdf0e10cSrcweir } 386cdf0e10cSrcweir //------------------------------------------------------------------------------ 387cdf0e10cSrcweir ImageList Condition::getImageList(sal_Int16 _eBitmapSet,sal_Bool _bHiContast) const 388cdf0e10cSrcweir { 389cdf0e10cSrcweir sal_Int16 nN = IMG_CONDFORMAT_DLG_SC; 390cdf0e10cSrcweir sal_Int16 nH = IMG_CONDFORMAT_DLG_SCH; 391cdf0e10cSrcweir if ( _eBitmapSet == SFX_SYMBOLS_SIZE_LARGE ) 392cdf0e10cSrcweir { 393cdf0e10cSrcweir nN = IMG_CONDFORMAT_DLG_LC; 394cdf0e10cSrcweir nH = IMG_CONDFORMAT_DLG_LCH; 395cdf0e10cSrcweir } 396cdf0e10cSrcweir return ImageList(ModuleRes( _bHiContast ? nH : nN )); 397cdf0e10cSrcweir } 398cdf0e10cSrcweir //------------------------------------------------------------------ 399cdf0e10cSrcweir void Condition::resizeControls(const Size& _rDiff) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir // we use large images so we must change them 402cdf0e10cSrcweir if ( _rDiff.Width() || _rDiff.Height() ) 403cdf0e10cSrcweir { 404cdf0e10cSrcweir Point aPos = LogicToPixel( Point( 2*RELATED_CONTROLS , 0), MAP_APPFONT ); 405cdf0e10cSrcweir Invalidate(); 406cdf0e10cSrcweir } 407cdf0e10cSrcweir } 408cdf0e10cSrcweir // ----------------------------------------------------------------------------- 409cdf0e10cSrcweir void Condition::Paint( const Rectangle& rRect ) 410cdf0e10cSrcweir { 411cdf0e10cSrcweir Control::Paint(rRect); 412cdf0e10cSrcweir 413cdf0e10cSrcweir // draw border 414cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 415cdf0e10cSrcweir ColorChanger aColors( this, rStyleSettings.GetShadowColor(), rStyleSettings.GetDialogColor() ); 416cdf0e10cSrcweir DrawRect( impl_getToolBarBorderRect() ); 417cdf0e10cSrcweir } 418cdf0e10cSrcweir // ----------------------------------------------------------------------------- 419cdf0e10cSrcweir void Condition::StateChanged( StateChangedType nType ) 420cdf0e10cSrcweir { 421cdf0e10cSrcweir Control::StateChanged( nType ); 422cdf0e10cSrcweir 423cdf0e10cSrcweir if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) 424cdf0e10cSrcweir { 425cdf0e10cSrcweir // Check if we need to get new images for normal/high contrast mode 426cdf0e10cSrcweir checkImageList(); 427cdf0e10cSrcweir } 428cdf0e10cSrcweir else if ( nType == STATE_CHANGE_TEXT ) 429cdf0e10cSrcweir { 430cdf0e10cSrcweir // The physical toolbar changed its outlook and shows another logical toolbar! 431cdf0e10cSrcweir // We have to set the correct high contrast mode on the new tbx manager. 432cdf0e10cSrcweir // pMgr->SetHiContrast( IsHiContrastMode() ); 433cdf0e10cSrcweir checkImageList(); 434cdf0e10cSrcweir } 435cdf0e10cSrcweir } 436cdf0e10cSrcweir // ----------------------------------------------------------------------------- 437cdf0e10cSrcweir void Condition::DataChanged( const DataChangedEvent& rDCEvt ) 438cdf0e10cSrcweir { 439cdf0e10cSrcweir Control::DataChanged( rDCEvt ); 440cdf0e10cSrcweir 441cdf0e10cSrcweir if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS ) || 442cdf0e10cSrcweir ( rDCEvt.GetType() == DATACHANGED_DISPLAY )) && 443cdf0e10cSrcweir ( rDCEvt.GetFlags() & SETTINGS_STYLE )) 444cdf0e10cSrcweir { 445cdf0e10cSrcweir // Check if we need to get new images for normal/high contrast mode 446cdf0e10cSrcweir checkImageList(); 447cdf0e10cSrcweir } 448cdf0e10cSrcweir } 449cdf0e10cSrcweir 450cdf0e10cSrcweir // ----------------------------------------------------------------------------- 451cdf0e10cSrcweir void Condition::GetFocus() 452cdf0e10cSrcweir { 453cdf0e10cSrcweir Control::GetFocus(); 454cdf0e10cSrcweir if ( !m_bInDestruction ) 455cdf0e10cSrcweir m_aCondLHS.GrabFocus(); 456cdf0e10cSrcweir } 457cdf0e10cSrcweir 458cdf0e10cSrcweir // ----------------------------------------------------------------------------- 459cdf0e10cSrcweir void Condition::Resize() 460cdf0e10cSrcweir { 461cdf0e10cSrcweir Control::Resize(); 462cdf0e10cSrcweir impl_layoutAll(); 463cdf0e10cSrcweir } 464cdf0e10cSrcweir 465cdf0e10cSrcweir // ----------------------------------------------------------------------------- 466cdf0e10cSrcweir Rectangle Condition::impl_getToolBarBorderRect() const 467cdf0e10cSrcweir { 468cdf0e10cSrcweir const Point aToolbarPos( m_aActions.GetPosPixel() ); 469cdf0e10cSrcweir const Size aToolbarSize( m_aActions.GetSizePixel() ); 470cdf0e10cSrcweir const Size aRelatedControls = LogicToPixel( Size( RELATED_CONTROLS, RELATED_CONTROLS ), MAP_APPFONT ); 471cdf0e10cSrcweir 472cdf0e10cSrcweir Rectangle aBorderRect( aToolbarPos, aToolbarSize ); 473cdf0e10cSrcweir aBorderRect.Left() -= aRelatedControls.Width(); 474cdf0e10cSrcweir aBorderRect.Top() -= aRelatedControls.Height(); 475cdf0e10cSrcweir aBorderRect.Right() += aRelatedControls.Width(); 476cdf0e10cSrcweir aBorderRect.Bottom() += aRelatedControls.Height(); 477cdf0e10cSrcweir 478cdf0e10cSrcweir return aBorderRect; 479cdf0e10cSrcweir } 480cdf0e10cSrcweir 481cdf0e10cSrcweir // ----------------------------------------------------------------------------- 482cdf0e10cSrcweir void Condition::impl_layoutAll() 483cdf0e10cSrcweir { 484cdf0e10cSrcweir // if our width changed, resize/-position some controls 485cdf0e10cSrcweir const Size aSize( GetOutputSizePixel() ); 486cdf0e10cSrcweir if ( aSize.Width() == m_nLastKnownWindowWidth ) 487cdf0e10cSrcweir return; 488cdf0e10cSrcweir 489cdf0e10cSrcweir m_nLastKnownWindowWidth = aSize.Width(); 490cdf0e10cSrcweir 491cdf0e10cSrcweir const Size aRelatedControls( LogicToPixel( Size( RELATED_CONTROLS, RELATED_CONTROLS ), MAP_APPFONT ) ); 492cdf0e10cSrcweir const Size aUnrelatedControls( LogicToPixel( Size( UNRELATED_CONTROLS, 0 ), MAP_APPFONT ) ); 493cdf0e10cSrcweir const Point aRow1( LogicToPixel( Point( 0, ROW_1_POS ), MAP_APPFONT ) ); 494cdf0e10cSrcweir const Point aRow3( LogicToPixel( Point( 0, ROW_3_POS ), MAP_APPFONT ) ); 495cdf0e10cSrcweir 496cdf0e10cSrcweir // resize the header line 497cdf0e10cSrcweir m_aHeader.SetPosSizePixel( 0, 0, aSize.Width() - 2 * aRelatedControls.Width(), 0, WINDOW_POSSIZE_WIDTH ); 498cdf0e10cSrcweir 499cdf0e10cSrcweir // position the up/down buttons 500cdf0e10cSrcweir const Size aButtonSize( LogicToPixel( Size( IMAGE_BUTTON_WIDTH, IMAGE_BUTTON_HEIGHT ), MAP_APPFONT ) ); 501cdf0e10cSrcweir Point aButtonPos( aSize.Width() - aUnrelatedControls.Width() - aButtonSize.Width(), aRow1.Y() ); 502cdf0e10cSrcweir m_aMoveUp.SetPosSizePixel( aButtonPos.X(), aButtonPos.Y(), aButtonSize.Width(), aButtonSize.Height() ); 503cdf0e10cSrcweir aButtonPos.Move( 0, aButtonSize.Height() + aRelatedControls.Height() ); 504cdf0e10cSrcweir m_aMoveDown.SetPosSizePixel( aButtonPos.X(), aButtonPos.Y(), aButtonSize.Width(), aButtonSize.Height() ); 505cdf0e10cSrcweir 506cdf0e10cSrcweir // resize the preview 507cdf0e10cSrcweir const long nNewPreviewRight = aButtonPos.X() - aRelatedControls.Width(); 508cdf0e10cSrcweir 509cdf0e10cSrcweir const Point aPreviewPos( m_aPreview.GetPosPixel() ); 510cdf0e10cSrcweir OSL_ENSURE( aPreviewPos.X() < nNewPreviewRight, "Condition::impl_layoutAll: being *that* small should not be allowed!" ); 511cdf0e10cSrcweir m_aPreview.SetPosSizePixel( 0, 0, nNewPreviewRight - aPreviewPos.X(), 0, WINDOW_POSSIZE_WIDTH ); 512cdf0e10cSrcweir 513cdf0e10cSrcweir // position the add/remove buttons 514cdf0e10cSrcweir aButtonPos = Point( nNewPreviewRight - aButtonSize.Width(), aRow3.Y() ); 515cdf0e10cSrcweir m_aRemoveCondition.SetPosSizePixel( aButtonPos.X(), aButtonPos.Y(), aButtonSize.Width(), aButtonSize.Height() ); 516cdf0e10cSrcweir aButtonPos.Move( -( aButtonSize.Width() + aRelatedControls.Width() ), 0 ); 517cdf0e10cSrcweir m_aAddCondition.SetPosSizePixel( aButtonPos.X(), aButtonPos.Y(), aButtonSize.Width(), aButtonSize.Height() ); 518cdf0e10cSrcweir 519cdf0e10cSrcweir // layout the operands input controls 520cdf0e10cSrcweir impl_layoutOperands(); 521cdf0e10cSrcweir } 522cdf0e10cSrcweir 523cdf0e10cSrcweir // ----------------------------------------------------------------------------- 524cdf0e10cSrcweir IMPL_LINK( Condition, OnTypeSelected, ListBox*, /*_pNotInterestedIn*/ ) 525cdf0e10cSrcweir { 526cdf0e10cSrcweir impl_layoutOperands(); 527cdf0e10cSrcweir return 0L; 528cdf0e10cSrcweir } 529cdf0e10cSrcweir 530cdf0e10cSrcweir // ----------------------------------------------------------------------------- 531cdf0e10cSrcweir IMPL_LINK( Condition, OnOperationSelected, ListBox*, /*_pNotInterestedIn*/ ) 532cdf0e10cSrcweir { 533cdf0e10cSrcweir impl_layoutOperands(); 534cdf0e10cSrcweir return 0L; 535cdf0e10cSrcweir } 536cdf0e10cSrcweir 537cdf0e10cSrcweir // ----------------------------------------------------------------------------- 538cdf0e10cSrcweir void Condition::impl_layoutOperands() 539cdf0e10cSrcweir { 540cdf0e10cSrcweir const ConditionType eType( impl_getCurrentConditionType() ); 541cdf0e10cSrcweir const ComparisonOperation eOperation( impl_getCurrentComparisonOperation() ); 542cdf0e10cSrcweir 543cdf0e10cSrcweir const bool bIsExpression = ( eType == eExpression ); 544cdf0e10cSrcweir const bool bHaveRHS = 545cdf0e10cSrcweir ( ( eType == eFieldValueComparison ) 546cdf0e10cSrcweir && ( ( eOperation == eBetween ) 547cdf0e10cSrcweir || ( eOperation == eNotBetween ) 548cdf0e10cSrcweir ) 549cdf0e10cSrcweir ); 550cdf0e10cSrcweir 551cdf0e10cSrcweir const Size aRelatedControls( LogicToPixel( Size( RELATED_CONTROLS, 0 ), MAP_APPFONT ) ); 552cdf0e10cSrcweir const Rectangle aPreviewRect( m_aPreview.GetPosPixel(), m_aPreview.GetSizePixel() ); 553cdf0e10cSrcweir 554cdf0e10cSrcweir // the "condition type" list box 555cdf0e10cSrcweir const Rectangle aCondTypeRect( m_aConditionType.GetPosPixel(), m_aConditionType.GetSizePixel() ); 556cdf0e10cSrcweir const Point aOpListPos( aCondTypeRect.Right() + aRelatedControls.Width(), aCondTypeRect.Top() ); 557cdf0e10cSrcweir const Size aOpListSize( LogicToPixel( Size( COND_OP_WIDTH, 60 ), MAP_APPFONT ) ); 558cdf0e10cSrcweir m_aOperationList.SetPosSizePixel( aOpListPos.X(), aOpListPos.Y(),aOpListSize.Width(), aOpListSize.Height() ); 559cdf0e10cSrcweir m_aOperationList.Show( !bIsExpression ); 560cdf0e10cSrcweir 561cdf0e10cSrcweir // the LHS input field 562cdf0e10cSrcweir Point aLHSPos( aOpListPos.X() + aOpListSize.Width() + aRelatedControls.Width(), aOpListPos.Y() ); 563cdf0e10cSrcweir if ( bIsExpression ) 564cdf0e10cSrcweir aLHSPos.X() = aOpListPos.X(); 565cdf0e10cSrcweir Size aLHSSize( LogicToPixel( Size( EDIT_WIDTH, EDIT_HEIGHT ), MAP_APPFONT ) ); 566cdf0e10cSrcweir if ( !bHaveRHS ) 567cdf0e10cSrcweir aLHSSize.Width() = aPreviewRect.Right() - aLHSPos.X(); 568cdf0e10cSrcweir m_aCondLHS.SetPosSizePixel( aLHSPos.X(), aLHSPos.Y(), aLHSSize.Width(), aLHSSize.Height() ); 569cdf0e10cSrcweir 570cdf0e10cSrcweir if ( bHaveRHS ) 571cdf0e10cSrcweir { 572cdf0e10cSrcweir // the "and" text being the glue between LHS and RHS 573cdf0e10cSrcweir const Point aOpGluePos( aLHSPos.X() + aLHSSize.Width() + aRelatedControls.Width(), aLHSPos.Y() ); 574cdf0e10cSrcweir const Size aOpGlueSize( m_aOperandGlue.GetTextWidth( m_aOperandGlue.GetText() ) + aRelatedControls.Width(), aLHSSize.Height() ); 575cdf0e10cSrcweir m_aOperandGlue.SetPosSizePixel( aOpGluePos.X(), aOpGluePos.Y(), aOpGlueSize.Width(), aOpGlueSize.Height() ); 576cdf0e10cSrcweir 577cdf0e10cSrcweir // the RHS input field 578cdf0e10cSrcweir const Point aRHSPos( aOpGluePos.X() + aOpGlueSize.Width() + aRelatedControls.Width(), aOpGluePos.Y() ); 579cdf0e10cSrcweir const Size aRHSSize( aPreviewRect.Right() - aRHSPos.X(), aLHSSize.Height() ); 580cdf0e10cSrcweir m_aCondRHS.SetPosSizePixel( aRHSPos.X(), aRHSPos.Y(), aRHSSize.Width(), aRHSSize.Height() ); 581cdf0e10cSrcweir } 582cdf0e10cSrcweir 583cdf0e10cSrcweir m_aOperandGlue.Show( bHaveRHS ); 584cdf0e10cSrcweir m_aCondRHS.Show( bHaveRHS ); 585cdf0e10cSrcweir } 586cdf0e10cSrcweir 587cdf0e10cSrcweir // ----------------------------------------------------------------------------- 588cdf0e10cSrcweir void Condition::impl_setCondition( const ::rtl::OUString& _rConditionFormula ) 589cdf0e10cSrcweir { 590cdf0e10cSrcweir // determine the condition's type and comparison operation 591cdf0e10cSrcweir ConditionType eType( eFieldValueComparison ); 592cdf0e10cSrcweir ComparisonOperation eOperation( eBetween ); 593cdf0e10cSrcweir 594cdf0e10cSrcweir // LHS and RHS, matched below 595cdf0e10cSrcweir ::rtl::OUString sLHS, sRHS; 596cdf0e10cSrcweir 597cdf0e10cSrcweir if ( _rConditionFormula.getLength() ) 598cdf0e10cSrcweir { 599cdf0e10cSrcweir // the unprefixed expression which forms the condition 600cdf0e10cSrcweir ReportFormula aFormula( _rConditionFormula ); 601cdf0e10cSrcweir OSL_ENSURE( aFormula.getType() == ReportFormula::Expression, "Condition::setCondition: illegal formula!" ); 602cdf0e10cSrcweir ::rtl::OUString sExpression; 603cdf0e10cSrcweir if ( aFormula.getType() == ReportFormula::Expression ) 604cdf0e10cSrcweir sExpression = aFormula.getExpression(); 605cdf0e10cSrcweir // as fallback, if the below matching does not succeed, assume 606cdf0e10cSrcweir // the whole expression is the LHS 607cdf0e10cSrcweir eType = eExpression; 608cdf0e10cSrcweir sLHS = sExpression; 609cdf0e10cSrcweir 610cdf0e10cSrcweir // the data field (or expression) to which our control is bound 611cdf0e10cSrcweir const ReportFormula aFieldContentFormula( m_rAction.getDataField() ); 612cdf0e10cSrcweir const ::rtl::OUString sUnprefixedFieldContent( aFieldContentFormula.getBracketedFieldOrExpression() ); 613cdf0e10cSrcweir 614cdf0e10cSrcweir // check whether one of the Field Value Expression Factories recognizes the expression 615cdf0e10cSrcweir for ( ConditionalExpressions::const_iterator exp = m_aConditionalExpressions.begin(); 616cdf0e10cSrcweir exp != m_aConditionalExpressions.end(); 617cdf0e10cSrcweir ++exp 618cdf0e10cSrcweir ) 619cdf0e10cSrcweir { 620cdf0e10cSrcweir if ( exp->second->matchExpression( sExpression, sUnprefixedFieldContent, sLHS, sRHS ) ) 621cdf0e10cSrcweir { 622cdf0e10cSrcweir eType = eFieldValueComparison; 623cdf0e10cSrcweir eOperation = exp->first; 624cdf0e10cSrcweir break; 625cdf0e10cSrcweir } 626cdf0e10cSrcweir } 627cdf0e10cSrcweir } 628cdf0e10cSrcweir 629cdf0e10cSrcweir // update UI 630cdf0e10cSrcweir m_aConditionType.SelectEntryPos( (sal_uInt16)eType ); 631cdf0e10cSrcweir m_aOperationList.SelectEntryPos( (sal_uInt16)eOperation ); 632cdf0e10cSrcweir m_aCondLHS.SetText( sLHS ); 633cdf0e10cSrcweir m_aCondRHS.SetText( sRHS ); 634cdf0e10cSrcweir 635cdf0e10cSrcweir // re-layout 636cdf0e10cSrcweir impl_layoutOperands(); 637cdf0e10cSrcweir } 638cdf0e10cSrcweir 639cdf0e10cSrcweir // ----------------------------------------------------------------------------- 640cdf0e10cSrcweir void Condition::setCondition( const uno::Reference< report::XFormatCondition >& _rxCondition ) 641cdf0e10cSrcweir { 642cdf0e10cSrcweir OSL_PRECOND( _rxCondition.is(), "Condition::setCondition: empty condition object!" ); 643cdf0e10cSrcweir if ( !_rxCondition.is() ) 644cdf0e10cSrcweir return; 645cdf0e10cSrcweir 646cdf0e10cSrcweir ::rtl::OUString sConditionFormula; 647cdf0e10cSrcweir try 648cdf0e10cSrcweir { 649cdf0e10cSrcweir if ( _rxCondition.is() ) 650cdf0e10cSrcweir sConditionFormula = _rxCondition->getFormula(); 651cdf0e10cSrcweir } 652cdf0e10cSrcweir catch( const Exception& ) 653cdf0e10cSrcweir { 654cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 655cdf0e10cSrcweir } 656cdf0e10cSrcweir impl_setCondition( sConditionFormula ); 657cdf0e10cSrcweir updateToolbar( _rxCondition.get() ); 658cdf0e10cSrcweir } 659cdf0e10cSrcweir 660cdf0e10cSrcweir // ----------------------------------------------------------------------------- 661cdf0e10cSrcweir void Condition::updateToolbar(const uno::Reference< report::XReportControlFormat >& _xReportControlFormat) 662cdf0e10cSrcweir { 663cdf0e10cSrcweir OSL_ENSURE(_xReportControlFormat.is(),"XReportControlFormat is NULL!"); 664cdf0e10cSrcweir if ( _xReportControlFormat.is() ) 665cdf0e10cSrcweir { 666cdf0e10cSrcweir sal_uInt16 nItemCount = m_aActions.GetItemCount(); 667cdf0e10cSrcweir for (sal_uInt16 j = 0; j< nItemCount; ++j) 668cdf0e10cSrcweir { 669cdf0e10cSrcweir sal_uInt16 nItemId = m_aActions.GetItemId(j); 670cdf0e10cSrcweir m_aActions.CheckItem( nItemId, m_rController.isFormatCommandEnabled( nItemId, _xReportControlFormat ) ); 671cdf0e10cSrcweir } 672cdf0e10cSrcweir 673cdf0e10cSrcweir try 674cdf0e10cSrcweir { 675cdf0e10cSrcweir Font aBaseFont( Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont() ); 676cdf0e10cSrcweir SvxFont aFont( VCLUnoHelper::CreateFont( _xReportControlFormat->getFontDescriptor(), aBaseFont ) ); 677cdf0e10cSrcweir aFont.SetHeight( OutputDevice::LogicToLogic( Size( 0, (sal_Int32)aFont.GetHeight() ), MAP_POINT, MAP_TWIP ).Height()); 678cdf0e10cSrcweir aFont.SetEmphasisMark( static_cast< FontEmphasisMark >( _xReportControlFormat->getControlTextEmphasis() ) ); 679cdf0e10cSrcweir aFont.SetRelief( static_cast< FontRelief >( _xReportControlFormat->getCharRelief() ) ); 680cdf0e10cSrcweir aFont.SetColor( _xReportControlFormat->getCharColor() ); 681cdf0e10cSrcweir m_aPreview.SetFont( aFont ); 682cdf0e10cSrcweir m_aPreview.SetBackColor( _xReportControlFormat->getControlBackground() ); 683cdf0e10cSrcweir m_aPreview.SetTextLineColor( Color( _xReportControlFormat->getCharUnderlineColor() ) ); 684cdf0e10cSrcweir } 685cdf0e10cSrcweir catch( const Exception& ) 686cdf0e10cSrcweir { 687cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 688cdf0e10cSrcweir } 689cdf0e10cSrcweir } 690cdf0e10cSrcweir } 691cdf0e10cSrcweir // ----------------------------------------------------------------------------- 692cdf0e10cSrcweir void Condition::fillFormatCondition(const uno::Reference< report::XFormatCondition >& _xCondition) 693cdf0e10cSrcweir { 694cdf0e10cSrcweir const ConditionType eType( impl_getCurrentConditionType() ); 695cdf0e10cSrcweir const ComparisonOperation eOperation( impl_getCurrentComparisonOperation() ); 696cdf0e10cSrcweir 697cdf0e10cSrcweir const ::rtl::OUString sLHS( m_aCondLHS.GetText() ); 698cdf0e10cSrcweir const ::rtl::OUString sRHS( m_aCondRHS.GetText() ); 699cdf0e10cSrcweir 700cdf0e10cSrcweir ::rtl::OUString sUndecoratedFormula( sLHS ); 701cdf0e10cSrcweir 702cdf0e10cSrcweir if ( eType == eFieldValueComparison ) 703cdf0e10cSrcweir { 704cdf0e10cSrcweir ReportFormula aFieldContentFormula( m_rAction.getDataField() ); 705cdf0e10cSrcweir ::rtl::OUString sUnprefixedFieldContent( aFieldContentFormula.getBracketedFieldOrExpression() ); 706cdf0e10cSrcweir 707cdf0e10cSrcweir PConditionalExpression pFactory( m_aConditionalExpressions[ eOperation ] ); 708cdf0e10cSrcweir sUndecoratedFormula = pFactory->assembleExpression( sUnprefixedFieldContent, sLHS, sRHS ); 709cdf0e10cSrcweir } 710cdf0e10cSrcweir 711cdf0e10cSrcweir ReportFormula aFormula( ReportFormula::Expression, sUndecoratedFormula ); 712cdf0e10cSrcweir _xCondition->setFormula( aFormula.getCompleteFormula() ); 713cdf0e10cSrcweir } 714cdf0e10cSrcweir // ----------------------------------------------------------------------------- 715cdf0e10cSrcweir void Condition::setConditionIndex( size_t _nCondIndex, size_t _nCondCount ) 716cdf0e10cSrcweir { 717cdf0e10cSrcweir m_nCondIndex = _nCondIndex; 718cdf0e10cSrcweir String sHeader( ModuleRes( STR_NUMBERED_CONDITION ) ); 719cdf0e10cSrcweir sHeader.SearchAndReplaceAscii( "$number$", String::CreateFromInt32( _nCondIndex + 1 ) ); 720cdf0e10cSrcweir m_aHeader.SetText( sHeader ); 721cdf0e10cSrcweir 722cdf0e10cSrcweir m_aMoveUp.Enable( _nCondIndex > 0 ); 723cdf0e10cSrcweir OSL_PRECOND( _nCondCount > 0, "Condition::setConditionIndex: having no conditions at all is nonsense!" ); 724cdf0e10cSrcweir m_aMoveDown.Enable( _nCondIndex < _nCondCount - 1 ); 725cdf0e10cSrcweir } 726cdf0e10cSrcweir 727cdf0e10cSrcweir // ----------------------------------------------------------------------------- 728cdf0e10cSrcweir bool Condition::isEmpty() const 729cdf0e10cSrcweir { 730cdf0e10cSrcweir return m_aCondLHS.GetText().Len() == 0; 731cdf0e10cSrcweir } 732cdf0e10cSrcweir 733cdf0e10cSrcweir // ============================================================================= 734cdf0e10cSrcweir } // rptui 735cdf0e10cSrcweir // ============================================================================= 736cdf0e10cSrcweir 737