1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_extensions.hxx"
26 #include "browserview.hxx"
27 #include "propertyeditor.hxx"
28 #include "propctrlr.hrc"
29 #include <tools/debug.hxx>
30 #include <memory>
31 
32 //............................................................................
33 namespace pcr
34 {
35 //............................................................................
36 
37 	using namespace ::com::sun::star::uno;
38 	using namespace ::com::sun::star::lang;
39 
40 
41 	//========================================================================
42 	//= class OPropertyBrowserView
43 	//========================================================================
DBG_NAME(OPropertyBrowserView)44 	DBG_NAME(OPropertyBrowserView)
45 	//------------------------------------------------------------------------
46 	OPropertyBrowserView::OPropertyBrowserView( const Reference< XMultiServiceFactory >& _rxORB,
47 								 Window* _pParent, WinBits nBits)
48 				  :Window(_pParent, nBits | WB_3DLOOK)
49 				  ,m_xORB(_rxORB)
50 				  ,m_nActivePage(0)
51 	{
52 		DBG_CTOR(OPropertyBrowserView,NULL);
53 
54 		m_pPropBox = new OPropertyEditor( this );
55 		m_pPropBox->SetHelpId(HID_FM_PROPDLG_TABCTR);
56 		m_pPropBox->setPageActivationHandler(LINK(this, OPropertyBrowserView, OnPageActivation));
57 
58 		m_pPropBox->Show();
59 	}
60 
61 	//------------------------------------------------------------------------
IMPL_LINK(OPropertyBrowserView,OnPageActivation,void *,EMPTYARG)62 	IMPL_LINK(OPropertyBrowserView, OnPageActivation, void*, EMPTYARG)
63 	{
64 		m_nActivePage = m_pPropBox->GetCurPage();
65 		if (m_aPageActivationHandler.IsSet())
66 			m_aPageActivationHandler.Call(NULL);
67 		return 0L;
68 	}
69 
70 	//------------------------------------------------------------------------
~OPropertyBrowserView()71 	OPropertyBrowserView::~OPropertyBrowserView()
72 	{
73 		if(m_pPropBox)
74 		{
75 			sal_uInt16 nTmpPage = m_pPropBox->GetCurPage();
76 			if (nTmpPage)
77 				m_nActivePage = nTmpPage;
78 			::std::auto_ptr<Window> aTemp(m_pPropBox);
79 			m_pPropBox = NULL;
80 		}
81 		m_xORB = NULL;
82 
83 		DBG_DTOR(OPropertyBrowserView, NULL);
84 	}
85 
86 	//------------------------------------------------------------------------
activatePage(sal_uInt16 _nPage)87 	void OPropertyBrowserView::activatePage(sal_uInt16 _nPage)
88 	{
89 		m_nActivePage = _nPage;
90 		getPropertyBox().SetPage(m_nActivePage);
91 	}
92 
93 	//------------------------------------------------------------------------
GetFocus()94 	void OPropertyBrowserView::GetFocus()
95 	{
96 		if (m_pPropBox)
97 			m_pPropBox->GrabFocus();
98 		else
99 			Window::GetFocus();
100 	}
101 
102 	//------------------------------------------------------------------------
Notify(NotifyEvent & _rNEvt)103 	long OPropertyBrowserView::Notify( NotifyEvent& _rNEvt )
104     {
105 		if ( EVENT_KEYINPUT == _rNEvt.GetType() )
106 		{
107 			sal_uInt16 nKey = _rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
108 
109 			if ( ( KEY_DELETE == nKey ) || ( KEY_BACKSPACE == nKey ) )
110                 // silence this, we don't want to propagate this outside the property
111                 // browser, as it will probably do harm there
112                 // #i63285# / 2006-12-06 / frank.schoenheit@sun.com
113 				return 1;
114 		}
115         return Window::Notify( _rNEvt );
116     }
117 
118 	//------------------------------------------------------------------------
Resize()119 	void OPropertyBrowserView::Resize()
120 	{
121 		Size aSize = GetOutputSizePixel();
122 		m_pPropBox->SetSizePixel(aSize);
123 	}
124 
125 	// #95343# ---------------------------------------------------------------
getMinimumSize()126 	::com::sun::star::awt::Size OPropertyBrowserView::getMinimumSize()
127 	{
128 		Size aSize = GetOutputSizePixel();
129 		if( m_pPropBox )
130         {
131 		    aSize.setHeight( m_pPropBox->getMinimumHeight() );
132 			aSize.setWidth( m_pPropBox->getMinimumWidth() );
133         }
134 		return ::com::sun::star::awt::Size( aSize.Width(), aSize.Height() );
135 	}
136 
137 //............................................................................
138 } // namespace pcr
139 //............................................................................
140 
141