1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include "browserview.hxx"
31 #include "propertyeditor.hxx"
32 #include "propctrlr.hrc"
33 #include <tools/debug.hxx>
34 #include <memory>
35 
36 //............................................................................
37 namespace pcr
38 {
39 //............................................................................
40 
41 	using namespace ::com::sun::star::uno;
42 	using namespace ::com::sun::star::lang;
43 
44 
45 	//========================================================================
46 	//= class OPropertyBrowserView
47 	//========================================================================
48 	DBG_NAME(OPropertyBrowserView)
49 	//------------------------------------------------------------------------
50 	OPropertyBrowserView::OPropertyBrowserView( const Reference< XMultiServiceFactory >& _rxORB,
51 								 Window* _pParent, WinBits nBits)
52 				  :Window(_pParent, nBits | WB_3DLOOK)
53 				  ,m_xORB(_rxORB)
54 				  ,m_nActivePage(0)
55 	{
56 		DBG_CTOR(OPropertyBrowserView,NULL);
57 
58 		m_pPropBox = new OPropertyEditor( this );
59 		m_pPropBox->SetHelpId(HID_FM_PROPDLG_TABCTR);
60 		m_pPropBox->setPageActivationHandler(LINK(this, OPropertyBrowserView, OnPageActivation));
61 
62 		m_pPropBox->Show();
63 	}
64 
65 	//------------------------------------------------------------------------
66 	IMPL_LINK(OPropertyBrowserView, OnPageActivation, void*, EMPTYARG)
67 	{
68 		m_nActivePage = m_pPropBox->GetCurPage();
69 		if (m_aPageActivationHandler.IsSet())
70 			m_aPageActivationHandler.Call(NULL);
71 		return 0L;
72 	}
73 
74 	//------------------------------------------------------------------------
75 	OPropertyBrowserView::~OPropertyBrowserView()
76 	{
77 		if(m_pPropBox)
78 		{
79 			sal_uInt16 nTmpPage = m_pPropBox->GetCurPage();
80 			if (nTmpPage)
81 				m_nActivePage = nTmpPage;
82 			::std::auto_ptr<Window> aTemp(m_pPropBox);
83 			m_pPropBox = NULL;
84 		}
85 		m_xORB = NULL;
86 
87 		DBG_DTOR(OPropertyBrowserView, NULL);
88 	}
89 
90 	//------------------------------------------------------------------------
91 	void OPropertyBrowserView::activatePage(sal_uInt16 _nPage)
92 	{
93 		m_nActivePage = _nPage;
94 		getPropertyBox().SetPage(m_nActivePage);
95 	}
96 
97 	//------------------------------------------------------------------------
98 	void OPropertyBrowserView::GetFocus()
99 	{
100 		if (m_pPropBox)
101 			m_pPropBox->GrabFocus();
102 		else
103 			Window::GetFocus();
104 	}
105 
106 	//------------------------------------------------------------------------
107 	long OPropertyBrowserView::Notify( NotifyEvent& _rNEvt )
108     {
109 		if ( EVENT_KEYINPUT == _rNEvt.GetType() )
110 		{
111 			sal_uInt16 nKey = _rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
112 
113 			if ( ( KEY_DELETE == nKey ) || ( KEY_BACKSPACE == nKey ) )
114                 // silence this, we don't want to propagate this outside the property
115                 // browser, as it will probably do harm there
116                 // #i63285# / 2006-12-06 / frank.schoenheit@sun.com
117 				return 1;
118 		}
119         return Window::Notify( _rNEvt );
120     }
121 
122 	//------------------------------------------------------------------------
123 	void OPropertyBrowserView::Resize()
124 	{
125 		Size aSize = GetOutputSizePixel();
126 		m_pPropBox->SetSizePixel(aSize);
127 	}
128 
129 	// #95343# ---------------------------------------------------------------
130 	::com::sun::star::awt::Size OPropertyBrowserView::getMinimumSize()
131 	{
132 		Size aSize = GetOutputSizePixel();
133 		if( m_pPropBox )
134         {
135 		    aSize.setHeight( m_pPropBox->getMinimumHeight() );
136 			aSize.setWidth( m_pPropBox->getMinimumWidth() );
137         }
138 		return ::com::sun::star::awt::Size( aSize.Width(), aSize.Height() );
139 	}
140 
141 //............................................................................
142 } // namespace pcr
143 //............................................................................
144 
145