LibreOffice Module forms (master) 1
GroupBox.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include "GroupBox.hxx"
21#include <frm_strings.hxx>
22#include <services.hxx>
24#include <tools/debug.hxx>
25#include <com/sun/star/form/FormComponentType.hpp>
26
27namespace frm
28{
29
30using namespace ::com::sun::star::uno;
31using namespace ::com::sun::star::sdb;
32using namespace ::com::sun::star::sdbc;
33using namespace ::com::sun::star::beans;
34using namespace ::com::sun::star::container;
35using namespace ::com::sun::star::form;
36using namespace ::com::sun::star::awt;
37using namespace ::com::sun::star::io;
38using namespace ::com::sun::star::lang;
39using namespace ::com::sun::star::util;
40using namespace comphelper;
41
42// OGroupBoxModel
43
44
45OGroupBoxModel::OGroupBoxModel(const Reference<XComponentContext>& _rxFactory)
46 :OControlModel(_rxFactory, VCL_CONTROLMODEL_GROUPBOX, VCL_CONTROL_GROUPBOX)
47{
48 m_nClassId = FormComponentType::GROUPBOX;
49}
50
51
52OGroupBoxModel::OGroupBoxModel( const OGroupBoxModel* _pOriginal, const Reference<XComponentContext>& _rxFactory )
53 :OControlModel( _pOriginal, _rxFactory )
54{
55}
56
57// XServiceInfo
58
59css::uno::Sequence<OUString> SAL_CALL OGroupBoxModel::getSupportedServiceNames()
60{
61 css::uno::Sequence<OUString> aSupported = OControlModel::getSupportedServiceNames();
62 aSupported.realloc(aSupported.getLength() + 2);
63
64 OUString* pArray = aSupported.getArray();
65 pArray[aSupported.getLength()-2] = FRM_SUN_COMPONENT_GROUPBOX;
66 pArray[aSupported.getLength()-1] = FRM_COMPONENT_GROUPBOX;
67 return aSupported;
68}
69
70
71OGroupBoxModel::~OGroupBoxModel()
72{
73}
74
75
76css::uno::Reference< css::util::XCloneable > SAL_CALL OGroupBoxModel::createClone()
77{
78 rtl::Reference<OGroupBoxModel> pClone = new OGroupBoxModel(this, getContext());
79 pClone->clonedFrom(this);
80 return pClone;
81}
82
83
84void OGroupBoxModel::describeAggregateProperties( Sequence< Property >& _rAggregateProps ) const
85{
86 OControlModel::describeAggregateProperties( _rAggregateProps );
87 // don't want to have the TabStop property
88 RemoveProperty(_rAggregateProps, PROPERTY_TABSTOP);
89}
90
91
92OUString SAL_CALL OGroupBoxModel::getServiceName()
93{
94 return FRM_COMPONENT_GROUPBOX; // old (non-sun) name for compatibility !
95}
96
97
98void SAL_CALL OGroupBoxModel::write(const Reference< XObjectOutputStream>& _rxOutStream)
99{
100 OControlModel::write(_rxOutStream);
101
102 // Version
103 _rxOutStream->writeShort(0x0002);
104 writeHelpTextCompatibly(_rxOutStream);
105}
106
107
108void SAL_CALL OGroupBoxModel::read(const Reference< XObjectInputStream>& _rxInStream)
109{
110 OControlModel::read( _rxInStream );
111
112 // Version
113 sal_uInt16 nVersion = _rxInStream->readShort();
114 DBG_ASSERT(nVersion > 0, "OGroupBoxModel::read : version 0 ? this should never have been written !");
115
116 if (nVersion == 2)
117 readHelpTextCompatibly(_rxInStream);
118
119 if (nVersion > 0x0002)
120 {
121 OSL_FAIL("OGroupBoxModel::read : unknown version !");
122 }
123};
124
125
126// OGroupBoxControl
127
128OGroupBoxControl::OGroupBoxControl(const Reference<XComponentContext>& _rxFactory)
129 :OControl(_rxFactory, VCL_CONTROL_GROUPBOX)
130{
131}
132
133
134css::uno::Sequence<OUString> SAL_CALL OGroupBoxControl::getSupportedServiceNames()
135{
136 css::uno::Sequence<OUString> aSupported = OControl::getSupportedServiceNames();
137 aSupported.realloc(aSupported.getLength() + 2);
138
139 OUString* pArray = aSupported.getArray();
140 pArray[aSupported.getLength()-2] = FRM_SUN_CONTROL_GROUPBOX;
141 pArray[aSupported.getLength()-1] = STARDIV_ONE_FORM_CONTROL_GROUPBOX;
142 return aSupported;
143}
144
145}
146
147extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
148com_sun_star_form_OGroupBoxModel_get_implementation(css::uno::XComponentContext* component,
149 css::uno::Sequence<css::uno::Any> const &)
150{
151 return cppu::acquire(new frm::OGroupBoxModel(component));
152
153}
154
155extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
156com_sun_star_form_OGroupBoxControl_get_implementation(css::uno::XComponentContext* component,
157 css::uno::Sequence<css::uno::Any> const &)
158{
159 return cppu::acquire(new frm::OGroupBoxControl(component));
160}
161
162/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_form_OGroupBoxControl_get_implementation(css::uno::XComponentContext *component, css::uno::Sequence< css::uno::Any > const &)
Definition: GroupBox.cxx:156
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_form_OGroupBoxModel_get_implementation(css::uno::XComponentContext *component, css::uno::Sequence< css::uno::Any > const &)
Definition: GroupBox.cxx:148
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: GroupBox.cxx:134
OGroupBoxModel(const css::uno::Reference< css::uno::XComponentContext > &_rxFactory)
#define DBG_ASSERT(sCon, aError)
sal_Int16 nVersion
constexpr OUStringLiteral PROPERTY_TABSTOP
void RemoveProperty(Sequence< Property > &_rProps, const OUString &_rPropName)
ListBox is a bit confusing / different from other form components, so here are a few notes:
Definition: BaseListBox.hxx:25
constexpr OUStringLiteral FRM_SUN_CONTROL_GROUPBOX
Definition: services.hxx:154
constexpr OUStringLiteral STARDIV_ONE_FORM_CONTROL_GROUPBOX
Definition: services.hxx:95
constexpr OUStringLiteral VCL_CONTROL_GROUPBOX
Definition: services.hxx:27
constexpr OUStringLiteral FRM_COMPONENT_GROUPBOX
Definition: services.hxx:70
constexpr OUStringLiteral FRM_SUN_COMPONENT_GROUPBOX
Definition: services.hxx:117
constexpr OUStringLiteral VCL_CONTROLMODEL_GROUPBOX
Definition: services.hxx:43