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_forms.hxx"
30 #include "GroupBox.hxx"
31 #include "property.hxx"
32 #ifndef _FRM_PROPERTY_HRC_
33 #include "property.hrc"
34 #endif
35 #include "services.hxx"
36 #include <tools/debug.hxx>
37 
38 //.........................................................................
39 namespace frm
40 {
41 using namespace ::com::sun::star::uno;
42 using namespace ::com::sun::star::sdb;
43 using namespace ::com::sun::star::sdbc;
44 using namespace ::com::sun::star::sdbcx;
45 using namespace ::com::sun::star::beans;
46 using namespace ::com::sun::star::container;
47 using namespace ::com::sun::star::form;
48 using namespace ::com::sun::star::awt;
49 using namespace ::com::sun::star::io;
50 using namespace ::com::sun::star::lang;
51 using namespace ::com::sun::star::util;
52 
53 //==================================================================
54 // OGroupBoxModel
55 //==================================================================
56 
57 //------------------------------------------------------------------
58 InterfaceRef SAL_CALL OGroupBoxModel_CreateInstance(const Reference<starlang::XMultiServiceFactory>& _rxFactory) throw (RuntimeException)
59 {
60 	return *(new OGroupBoxModel(_rxFactory));
61 }
62 
63 //------------------------------------------------------------------
64 DBG_NAME( OGroupBoxModel )
65 //------------------------------------------------------------------
66 OGroupBoxModel::OGroupBoxModel(const Reference<starlang::XMultiServiceFactory>& _rxFactory)
67 	:OControlModel(_rxFactory, VCL_CONTROLMODEL_GROUPBOX, VCL_CONTROL_GROUPBOX)
68 {
69 	DBG_CTOR( OGroupBoxModel, NULL );
70 	m_nClassId = FormComponentType::GROUPBOX;
71 }
72 
73 //------------------------------------------------------------------
74 OGroupBoxModel::OGroupBoxModel( const OGroupBoxModel* _pOriginal, const Reference<starlang::XMultiServiceFactory>& _rxFactory )
75 	:OControlModel( _pOriginal, _rxFactory )
76 {
77 	DBG_CTOR( OGroupBoxModel, NULL );
78 }
79 
80 // XServiceInfo
81 //------------------------------------------------------------------------------
82 StringSequence SAL_CALL	OGroupBoxModel::getSupportedServiceNames() throw(RuntimeException)
83 {
84 	StringSequence aSupported = OControlModel::getSupportedServiceNames();
85 	aSupported.realloc(aSupported.getLength() + 1);
86 
87 	::rtl::OUString* pArray = aSupported.getArray();
88 	pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_GROUPBOX;
89 	return aSupported;
90 }
91 
92 //------------------------------------------------------------------
93 OGroupBoxModel::~OGroupBoxModel()
94 {
95 	DBG_DTOR( OGroupBoxModel, NULL );
96 }
97 
98 //------------------------------------------------------------------------------
99 IMPLEMENT_DEFAULT_CLONING( OGroupBoxModel )
100 
101 //------------------------------------------------------------------------------
102 void OGroupBoxModel::describeAggregateProperties( Sequence< Property >& _rAggregateProps ) const
103 {
104     OControlModel::describeAggregateProperties( _rAggregateProps );
105 	// don't want to have the TabStop property
106 	RemoveProperty(_rAggregateProps, PROPERTY_TABSTOP);
107 }
108 
109 //------------------------------------------------------------------------------
110 ::rtl::OUString SAL_CALL OGroupBoxModel::getServiceName() throw(RuntimeException)
111 {
112 	return FRM_COMPONENT_GROUPBOX;	// old (non-sun) name for compatibility !
113 }
114 
115 //------------------------------------------------------------------------------
116 void SAL_CALL OGroupBoxModel::write(const Reference< XObjectOutputStream>& _rxOutStream)
117 	throw(IOException, RuntimeException)
118 {
119 	OControlModel::write(_rxOutStream);
120 
121 	// Version
122 	_rxOutStream->writeShort(0x0002);
123 	writeHelpTextCompatibly(_rxOutStream);
124 }
125 
126 //------------------------------------------------------------------------------
127 void SAL_CALL OGroupBoxModel::read(const Reference< XObjectInputStream>& _rxInStream) throw(IOException, RuntimeException)
128 {
129 	OControlModel::read( _rxInStream );
130 
131 	// Version
132 	sal_uInt16 nVersion = _rxInStream->readShort();
133 	DBG_ASSERT(nVersion > 0, "OGroupBoxModel::read : version 0 ? this should never have been written !");
134 		// ups, ist das Englisch richtig ? ;)
135 
136 	if (nVersion == 2)
137 		readHelpTextCompatibly(_rxInStream);
138 
139 	if (nVersion > 0x0002)
140 	{
141 		DBG_ERROR("OGroupBoxModel::read : unknown version !");
142 	}
143 };
144 
145 //==================================================================
146 // OGroupBoxControl
147 //==================================================================
148 
149 //------------------------------------------------------------------
150 InterfaceRef SAL_CALL OGroupBoxControl_CreateInstance(const Reference<starlang::XMultiServiceFactory>& _rxFactory) throw (RuntimeException)
151 {
152 	return *(new OGroupBoxControl(_rxFactory));
153 }
154 
155 //------------------------------------------------------------------------------
156 OGroupBoxControl::OGroupBoxControl(const Reference<starlang::XMultiServiceFactory>& _rxFactory)
157 			       :OControl(_rxFactory, VCL_CONTROL_GROUPBOX)
158 {
159 }
160 
161 //------------------------------------------------------------------------------
162 StringSequence SAL_CALL	OGroupBoxControl::getSupportedServiceNames() throw(RuntimeException)
163 {
164 	StringSequence aSupported = OControl::getSupportedServiceNames();
165 	aSupported.realloc(aSupported.getLength() + 1);
166 
167 	::rtl::OUString* pArray = aSupported.getArray();
168 	pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_GROUPBOX;
169 	return aSupported;
170 }
171 
172 //.........................................................................
173 }
174 //.........................................................................
175 
176