1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_extensions.hxx" 30*cdf0e10cSrcweir #include "browserline.hxx" 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir /** === begin UNO includes === **/ 33*cdf0e10cSrcweir #include <com/sun/star/inspection/PropertyLineElement.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphicProvider.hpp> 35*cdf0e10cSrcweir /** === end UNO includes === **/ 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <vcl/svapp.hxx> 38*cdf0e10cSrcweir #include <tools/debug.hxx> 39*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 40*cdf0e10cSrcweir #include <tools/urlobj.hxx> 41*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 44*cdf0e10cSrcweir #include <comphelper/componentcontext.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir //............................................................................ 47*cdf0e10cSrcweir namespace pcr 48*cdf0e10cSrcweir { 49*cdf0e10cSrcweir //............................................................................ 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir /** === begin UNO using === **/ 52*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 53*cdf0e10cSrcweir using ::com::sun::star::inspection::XPropertyControl; 54*cdf0e10cSrcweir using ::com::sun::star::inspection::XPropertyControlContext; 55*cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY_THROW; 56*cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 57*cdf0e10cSrcweir using ::com::sun::star::graphic::XGraphicProvider; 58*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 59*cdf0e10cSrcweir using ::com::sun::star::beans::PropertyValue; 60*cdf0e10cSrcweir using ::com::sun::star::graphic::XGraphic; 61*cdf0e10cSrcweir /** === end UNO using === **/ 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir namespace PropertyLineElement = ::com::sun::star::inspection::PropertyLineElement; 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir //================================================================== 66*cdf0e10cSrcweir //= OBrowserLine 67*cdf0e10cSrcweir //================================================================== 68*cdf0e10cSrcweir DBG_NAME(OBrowserLine) 69*cdf0e10cSrcweir //------------------------------------------------------------------ 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir OBrowserLine::OBrowserLine( const ::rtl::OUString& _rEntryName, Window* pParent ) 72*cdf0e10cSrcweir :m_sEntryName( _rEntryName ) 73*cdf0e10cSrcweir ,m_aFtTitle(pParent) 74*cdf0e10cSrcweir ,m_pControlWindow( NULL ) 75*cdf0e10cSrcweir ,m_pBrowseButton(NULL) 76*cdf0e10cSrcweir ,m_pAdditionalBrowseButton( NULL ) 77*cdf0e10cSrcweir ,m_pClickListener( NULL ) 78*cdf0e10cSrcweir ,m_pTheParent(pParent) 79*cdf0e10cSrcweir ,m_nNameWidth(0) 80*cdf0e10cSrcweir ,m_nEnableFlags( 0xFFFF ) 81*cdf0e10cSrcweir ,m_bIndentTitle( false ) 82*cdf0e10cSrcweir ,m_bReadOnly( false ) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir DBG_CTOR(OBrowserLine,NULL); 85*cdf0e10cSrcweir m_aFtTitle.Show(); 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir //------------------------------------------------------------------ 89*cdf0e10cSrcweir OBrowserLine::~OBrowserLine() 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir implHideBrowseButton( true, false ); 92*cdf0e10cSrcweir implHideBrowseButton( false, false ); 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir DBG_DTOR(OBrowserLine,NULL); 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir //------------------------------------------------------------------ 98*cdf0e10cSrcweir void OBrowserLine::IndentTitle( bool _bIndent ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir if ( m_bIndentTitle != _bIndent ) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir m_bIndentTitle = _bIndent; 103*cdf0e10cSrcweir impl_layoutComponents(); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir //------------------------------------------------------------------ 108*cdf0e10cSrcweir void OBrowserLine::SetComponentHelpIds( const rtl::OString& _rHelpId, const rtl::OString& _sPrimaryButtonId, const rtl::OString& _sSecondaryButtonId ) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir if ( m_pControlWindow ) 111*cdf0e10cSrcweir m_pControlWindow->SetHelpId( _rHelpId ); 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir if ( m_pBrowseButton ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir m_pBrowseButton->SetHelpId( _rHelpId ); 116*cdf0e10cSrcweir m_pBrowseButton->SetUniqueId( _sPrimaryButtonId ); 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir if ( m_pAdditionalBrowseButton ) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir m_pAdditionalBrowseButton->SetHelpId( _rHelpId ); 121*cdf0e10cSrcweir m_pAdditionalBrowseButton->SetUniqueId( _sSecondaryButtonId ); 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir //------------------------------------------------------------------ 127*cdf0e10cSrcweir void OBrowserLine::setControl( const Reference< XPropertyControl >& _rxControl ) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir m_xControl = _rxControl; 130*cdf0e10cSrcweir m_pControlWindow = m_xControl.is() ? VCLUnoHelper::GetWindow( _rxControl->getControlWindow() ) : NULL; 131*cdf0e10cSrcweir DBG_ASSERT( m_pControlWindow, "OBrowserLine::setControl: setting NULL controls/windows is not allowed!" ); 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir if ( m_pControlWindow ) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir m_pControlWindow->SetParent( m_pTheParent ); 136*cdf0e10cSrcweir m_pControlWindow->Show(); 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir impl_layoutComponents(); 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir //------------------------------------------------------------------ 142*cdf0e10cSrcweir Window* OBrowserLine::GetRefWindow() 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir Window* pRefWindow=&m_aFtTitle; 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir if(m_pBrowseButton) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir pRefWindow=(Window*)m_pBrowseButton; 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir else if ( m_pControlWindow ) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir pRefWindow = m_pControlWindow; 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir return pRefWindow; 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir //------------------------------------------------------------------ 158*cdf0e10cSrcweir void OBrowserLine::SetTabOrder(Window* pRefWindow, sal_uInt16 nFlags ) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir m_aFtTitle.SetZOrder(pRefWindow,nFlags); 161*cdf0e10cSrcweir if ( m_pControlWindow ) 162*cdf0e10cSrcweir m_pControlWindow->SetZOrder( (Window*)&m_aFtTitle, WINDOW_ZORDER_BEHIND ); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir if ( m_pBrowseButton ) 165*cdf0e10cSrcweir m_pBrowseButton->SetZOrder( m_pControlWindow, WINDOW_ZORDER_BEHIND ); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir if ( m_pAdditionalBrowseButton ) 168*cdf0e10cSrcweir m_pAdditionalBrowseButton->SetZOrder( m_pBrowseButton, WINDOW_ZORDER_BEHIND ); 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir //------------------------------------------------------------------ 172*cdf0e10cSrcweir sal_Bool OBrowserLine::GrabFocus() 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir sal_Bool bRes=sal_False; 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir if ( m_pControlWindow && m_pControlWindow->IsEnabled() ) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir m_pControlWindow->GrabFocus(); 179*cdf0e10cSrcweir bRes = sal_True; 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir else if ( m_pAdditionalBrowseButton && m_pAdditionalBrowseButton->IsEnabled() ) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir m_pAdditionalBrowseButton->GrabFocus(); 184*cdf0e10cSrcweir bRes = sal_True; 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir else if ( m_pBrowseButton && m_pBrowseButton->IsEnabled() ) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir m_pBrowseButton->GrabFocus(); 189*cdf0e10cSrcweir bRes = sal_True; 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir return bRes; 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir //------------------------------------------------------------------ 195*cdf0e10cSrcweir void OBrowserLine::SetPosSizePixel( Point _rPos, Size _rSize ) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir m_aLinePos = _rPos; 198*cdf0e10cSrcweir m_aOutputSize = _rSize; 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir impl_layoutComponents(); 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir //------------------------------------------------------------------ 204*cdf0e10cSrcweir void OBrowserLine::Show(sal_Bool bFlag) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir m_aFtTitle.Show(bFlag); 207*cdf0e10cSrcweir if ( m_pControlWindow ) 208*cdf0e10cSrcweir m_pControlWindow->Show( bFlag ); 209*cdf0e10cSrcweir if ( m_pBrowseButton ) 210*cdf0e10cSrcweir m_pBrowseButton->Show( bFlag ); 211*cdf0e10cSrcweir if ( m_pAdditionalBrowseButton ) 212*cdf0e10cSrcweir m_pAdditionalBrowseButton->Show( bFlag ); 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir //------------------------------------------------------------------ 216*cdf0e10cSrcweir void OBrowserLine::Hide() 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir Show(sal_False); 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir //------------------------------------------------------------------ 222*cdf0e10cSrcweir sal_Bool OBrowserLine::IsVisible() 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir return m_aFtTitle.IsVisible(); 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir //------------------------------------------------------------------ 228*cdf0e10cSrcweir void OBrowserLine::impl_layoutComponents() 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir Point aTitlePos( m_aLinePos.X(), m_aLinePos.Y() + 8 ); 232*cdf0e10cSrcweir Size aTitleSize( m_nNameWidth - 3, m_aOutputSize.Height() ); 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir if ( m_bIndentTitle ) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir Size aIndent( m_pTheParent->LogicToPixel( Size( 8, 0 ), MAP_APPFONT ) ); 237*cdf0e10cSrcweir aTitlePos.X() += aIndent.Width(); 238*cdf0e10cSrcweir aTitleSize.Width() -= aIndent.Width(); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir m_aFtTitle.SetPosSizePixel( aTitlePos, aTitleSize ); 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir sal_Int32 nBrowseButtonSize = m_aOutputSize.Height() - 4; 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir if ( m_pControlWindow ) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir Point aControlPos( m_aLinePos.X() + m_nNameWidth, m_aLinePos.Y() + 2 ); 248*cdf0e10cSrcweir m_pControlWindow->SetPosPixel( aControlPos ); 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir Size aControlSize( m_aOutputSize.Width() - 4 - m_nNameWidth - nBrowseButtonSize - 4, m_pControlWindow->GetSizePixel().Height() ); 251*cdf0e10cSrcweir if ( m_pAdditionalBrowseButton ) 252*cdf0e10cSrcweir aControlSize.Width() -= nBrowseButtonSize + 4; 253*cdf0e10cSrcweir m_pControlWindow->SetSizePixel( aControlSize ); 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir if ( m_pBrowseButton ) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir Point aButtonPos( m_aOutputSize.Width() - 4 - nBrowseButtonSize, m_aLinePos.Y() + 2 ); 259*cdf0e10cSrcweir Size aButtonSize( nBrowseButtonSize, nBrowseButtonSize ); 260*cdf0e10cSrcweir m_pBrowseButton->SetPosSizePixel( aButtonPos, aButtonSize ); 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir if ( m_pAdditionalBrowseButton ) 263*cdf0e10cSrcweir { 264*cdf0e10cSrcweir aButtonPos.X() -= nBrowseButtonSize + 4; 265*cdf0e10cSrcweir m_pAdditionalBrowseButton->SetPosSizePixel( aButtonPos, aButtonSize ); 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir //------------------------------------------------------------------ 271*cdf0e10cSrcweir void OBrowserLine::SetTitle(const XubString& _rNewTtile ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir if ( GetTitle() == _rNewTtile ) 274*cdf0e10cSrcweir return; 275*cdf0e10cSrcweir // #99102# -------------- 276*cdf0e10cSrcweir m_aFtTitle.SetText( _rNewTtile ); 277*cdf0e10cSrcweir if ( m_pControlWindow ) 278*cdf0e10cSrcweir m_pControlWindow->SetAccessibleName( _rNewTtile ); 279*cdf0e10cSrcweir if ( m_pBrowseButton ) 280*cdf0e10cSrcweir m_pBrowseButton->SetAccessibleName( _rNewTtile ); 281*cdf0e10cSrcweir FullFillTitleString(); 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir // #99102# --------------------------------------------------------- 285*cdf0e10cSrcweir void OBrowserLine::FullFillTitleString() 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir if( m_pTheParent ) 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir String aText = m_aFtTitle.GetText(); 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir while( m_pTheParent->GetTextWidth( aText ) < m_nNameWidth ) 292*cdf0e10cSrcweir aText.AppendAscii("..........."); 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir // for Issue 69452 295*cdf0e10cSrcweir if (Application::GetSettings().GetLayoutRTL()) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir sal_Unicode cRTL_mark = 0x200F; 298*cdf0e10cSrcweir aText.Append(cRTL_mark); 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir m_aFtTitle.SetText(aText); 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir } 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir //------------------------------------------------------------------ 306*cdf0e10cSrcweir XubString OBrowserLine::GetTitle() const 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir String sDisplayName = m_aFtTitle.GetText(); 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir // for Issue 69452 311*cdf0e10cSrcweir if (Application::GetSettings().GetLayoutRTL()) 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir sal_Unicode cRTL_mark = 0x200F; 314*cdf0e10cSrcweir sDisplayName.EraseTrailingChars(cRTL_mark); 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir sDisplayName.EraseTrailingChars( '.' ); 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir return sDisplayName; 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir //------------------------------------------------------------------ 323*cdf0e10cSrcweir void OBrowserLine::SetReadOnly( bool _bReadOnly ) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir if ( m_bReadOnly != _bReadOnly ) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir m_bReadOnly = _bReadOnly; 328*cdf0e10cSrcweir implUpdateEnabledDisabled(); 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir //------------------------------------------------------------------ 333*cdf0e10cSrcweir namespace 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir void implSetBitIfAffected( sal_uInt16& _nEnabledBits, sal_Int16 _nAffectedMask, sal_Int16 _nTestBit, bool _bSet ) 336*cdf0e10cSrcweir { 337*cdf0e10cSrcweir if ( _nAffectedMask & _nTestBit ) 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir if ( _bSet ) 340*cdf0e10cSrcweir _nEnabledBits |= _nTestBit; 341*cdf0e10cSrcweir else 342*cdf0e10cSrcweir _nEnabledBits &= ~_nTestBit; 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir void implEnable( Window* _pWindow, sal_uInt16 _nEnabledBits, sal_uInt16 _nMatchBits ) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir if ( _pWindow ) 349*cdf0e10cSrcweir _pWindow->Enable( ( _nEnabledBits & _nMatchBits ) == _nMatchBits ); 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir void implEnable( Window* _pWindow, bool _bEnable ) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir if ( _pWindow ) 355*cdf0e10cSrcweir _pWindow->Enable( _bEnable ); 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir //------------------------------------------------------------------ 360*cdf0e10cSrcweir void OBrowserLine::implUpdateEnabledDisabled() 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir implEnable( &m_aFtTitle, m_nEnableFlags, PropertyLineElement::CompleteLine ); 363*cdf0e10cSrcweir if ( m_pControlWindow ) 364*cdf0e10cSrcweir implEnable( m_pControlWindow, m_nEnableFlags, PropertyLineElement::CompleteLine | PropertyLineElement::InputControl ); 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir if ( m_bReadOnly ) 367*cdf0e10cSrcweir { 368*cdf0e10cSrcweir implEnable( m_pBrowseButton, false ); 369*cdf0e10cSrcweir implEnable( m_pAdditionalBrowseButton, false ); 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir else 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir implEnable( m_pBrowseButton, m_nEnableFlags, PropertyLineElement::CompleteLine | PropertyLineElement::PrimaryButton ); 374*cdf0e10cSrcweir implEnable( m_pAdditionalBrowseButton, m_nEnableFlags, PropertyLineElement::CompleteLine | PropertyLineElement::SecondaryButton ); 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir //------------------------------------------------------------------ 379*cdf0e10cSrcweir void OBrowserLine::EnablePropertyLine( bool _bEnable ) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir implSetBitIfAffected( m_nEnableFlags, PropertyLineElement::CompleteLine, PropertyLineElement::CompleteLine, _bEnable ); 382*cdf0e10cSrcweir implUpdateEnabledDisabled(); 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir //------------------------------------------------------------------ 386*cdf0e10cSrcweir void OBrowserLine::EnablePropertyControls( sal_Int16 _nControls, bool _bEnable ) 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir implSetBitIfAffected( m_nEnableFlags, _nControls, PropertyLineElement::InputControl, _bEnable ); 389*cdf0e10cSrcweir implSetBitIfAffected( m_nEnableFlags, _nControls, PropertyLineElement::PrimaryButton, _bEnable ); 390*cdf0e10cSrcweir implSetBitIfAffected( m_nEnableFlags, _nControls, PropertyLineElement::SecondaryButton, _bEnable ); 391*cdf0e10cSrcweir implUpdateEnabledDisabled(); 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir //------------------------------------------------------------------ 395*cdf0e10cSrcweir PushButton& OBrowserLine::impl_ensureButton( bool _bPrimary ) 396*cdf0e10cSrcweir { 397*cdf0e10cSrcweir PushButton*& rpButton = _bPrimary ? m_pBrowseButton : m_pAdditionalBrowseButton; 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir if ( !rpButton ) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir rpButton = new PushButton( m_pTheParent, WB_NOPOINTERFOCUS ); 402*cdf0e10cSrcweir rpButton->SetGetFocusHdl( LINK( this, OBrowserLine, OnButtonFocus ) ); 403*cdf0e10cSrcweir rpButton->SetClickHdl( LINK( this, OBrowserLine, OnButtonClicked ) ); 404*cdf0e10cSrcweir rpButton->SetText( String::CreateFromAscii( "..." ) ); 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir rpButton->Show(); 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir impl_layoutComponents(); 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir return *rpButton; 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir //------------------------------------------------------------------ 415*cdf0e10cSrcweir void OBrowserLine::impl_getImagesFromURL_nothrow( const ::rtl::OUString& _rImageURL, Image& _out_rImage, Image& _out_rHCImage ) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir try 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); 420*cdf0e10cSrcweir Reference< XGraphicProvider > xGraphicProvider( aContext.createComponent( "com.sun.star.graphic.GraphicProvider" ), UNO_QUERY_THROW ); 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir Sequence< PropertyValue > aMediaProperties(1); 423*cdf0e10cSrcweir aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ); 424*cdf0e10cSrcweir aMediaProperties[0].Value <<= _rImageURL; 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir Reference< XGraphic > xGraphic( xGraphicProvider->queryGraphic( aMediaProperties ), UNO_QUERY_THROW ); 427*cdf0e10cSrcweir _out_rImage = _out_rHCImage = Image( xGraphic ); 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir // see if we find an HC version beside the normal graphic 430*cdf0e10cSrcweir INetURLObject aURL( _rImageURL ); 431*cdf0e10cSrcweir ::rtl::OUString sBaseName( aURL.getBase() ); 432*cdf0e10cSrcweir aURL.setBase( sBaseName + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_hc" ) ) ); 433*cdf0e10cSrcweir ::rtl::OUString sHCImageURL( aURL.GetMainURL( INetURLObject::NO_DECODE ) ); 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir Reference< XGraphic > xHCGraphic; 436*cdf0e10cSrcweir try 437*cdf0e10cSrcweir { 438*cdf0e10cSrcweir aMediaProperties[0].Value <<= sHCImageURL; 439*cdf0e10cSrcweir xHCGraphic = xGraphicProvider->queryGraphic( aMediaProperties ); 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir catch( const Exception& ) { } 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir if ( xHCGraphic.is() ) 444*cdf0e10cSrcweir _out_rHCImage = Image( xHCGraphic ); 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir catch( const Exception& ) 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 449*cdf0e10cSrcweir } 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir //------------------------------------------------------------------ 453*cdf0e10cSrcweir void OBrowserLine::ShowBrowseButton( const ::rtl::OUString& _rImageURL, sal_Bool _bPrimary ) 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir PushButton& rButton( impl_ensureButton( _bPrimary ) ); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir OSL_PRECOND( _rImageURL.getLength(), "OBrowserLine::ShowBrowseButton: use the other version if you don't have an image!" ); 458*cdf0e10cSrcweir Image aImage, aHCImage; 459*cdf0e10cSrcweir impl_getImagesFromURL_nothrow( _rImageURL, aImage, aHCImage ); 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir rButton.SetModeImage( aImage, BMP_COLOR_NORMAL ); 462*cdf0e10cSrcweir rButton.SetModeImage( aHCImage, BMP_COLOR_HIGHCONTRAST ); 463*cdf0e10cSrcweir } 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir //------------------------------------------------------------------ 466*cdf0e10cSrcweir void OBrowserLine::ShowBrowseButton( const Image& _rImage, sal_Bool _bPrimary ) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir PushButton& rButton( impl_ensureButton( _bPrimary ) ); 469*cdf0e10cSrcweir if ( !!_rImage ) 470*cdf0e10cSrcweir rButton.SetModeImage( _rImage ); 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir //------------------------------------------------------------------ 474*cdf0e10cSrcweir void OBrowserLine::ShowBrowseButton( sal_Bool _bPrimary ) 475*cdf0e10cSrcweir { 476*cdf0e10cSrcweir impl_ensureButton( _bPrimary ); 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir //------------------------------------------------------------------ 480*cdf0e10cSrcweir void OBrowserLine::implHideBrowseButton( sal_Bool _bPrimary, bool _bReLayout ) 481*cdf0e10cSrcweir { 482*cdf0e10cSrcweir PushButton*& rpButton = _bPrimary ? m_pBrowseButton : m_pAdditionalBrowseButton; 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir if ( rpButton ) 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir rpButton->Hide(); 487*cdf0e10cSrcweir delete rpButton; 488*cdf0e10cSrcweir rpButton = NULL; 489*cdf0e10cSrcweir } 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir if ( _bReLayout ) 492*cdf0e10cSrcweir impl_layoutComponents(); 493*cdf0e10cSrcweir } 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir //------------------------------------------------------------------ 496*cdf0e10cSrcweir void OBrowserLine::HideBrowseButton( sal_Bool _bPrimary ) 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir implHideBrowseButton( _bPrimary, true ); 499*cdf0e10cSrcweir } 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir //------------------------------------------------------------------ 502*cdf0e10cSrcweir void OBrowserLine::SetTitleWidth(sal_uInt16 nWidth) 503*cdf0e10cSrcweir { 504*cdf0e10cSrcweir if (m_nNameWidth != nWidth+10) 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir m_nNameWidth = nWidth+10; 507*cdf0e10cSrcweir impl_layoutComponents(); 508*cdf0e10cSrcweir } 509*cdf0e10cSrcweir // #99102# --------- 510*cdf0e10cSrcweir FullFillTitleString(); 511*cdf0e10cSrcweir } 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir //------------------------------------------------------------------ 514*cdf0e10cSrcweir void OBrowserLine::SetClickListener( IButtonClickListener* _pListener ) 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir m_pClickListener = _pListener; 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir //------------------------------------------------------------------ 520*cdf0e10cSrcweir IMPL_LINK( OBrowserLine, OnButtonClicked, PushButton*, _pButton ) 521*cdf0e10cSrcweir { 522*cdf0e10cSrcweir if ( m_pClickListener ) 523*cdf0e10cSrcweir m_pClickListener->buttonClicked( this, _pButton == m_pBrowseButton ); 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir return 0L; 526*cdf0e10cSrcweir } 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir //------------------------------------------------------------------ 529*cdf0e10cSrcweir IMPL_LINK( OBrowserLine, OnButtonFocus, PushButton*, /*pPB*/ ) 530*cdf0e10cSrcweir { 531*cdf0e10cSrcweir if ( m_xControl.is() ) 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir try 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir Reference< XPropertyControlContext > xContext( m_xControl->getControlContext(), UNO_QUERY_THROW ); 536*cdf0e10cSrcweir xContext->focusGained( m_xControl ); 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir catch( const Exception& ) 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir return 0; 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir //............................................................................ 546*cdf0e10cSrcweir } // namespace pcr 547*cdf0e10cSrcweir //............................................................................ 548*cdf0e10cSrcweir 549