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