bump product version to 6.3.0.0.beta1
[LibreOffice.git] / reportdesign / source / ui / inspection / DefaultInspection.cxx
blob2067652f413a0c2bcb443bc7cb418c708b14f5a8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include <DefaultInspection.hxx>
20 #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
21 #include <com/sun/star/lang/IllegalArgumentException.hpp>
22 #include <strings.hrc>
23 #include <core_resource.hxx>
24 #include <helpids.h>
25 #include <cppuhelper/supportsservice.hxx>
26 #include <rtl/ustrbuf.hxx>
27 #include <tools/debug.hxx>
28 #include <metadata.hxx>
29 #include <tools/urlobj.hxx>
32 namespace rptui
34 OUString HelpIdUrl::getHelpURL( const OString& sHelpId )
36 OUString aTmp( OStringToOUString(sHelpId, RTL_TEXTENCODING_UTF8) );
37 DBG_ASSERT( INetURLObject( aTmp ).GetProtocol() == INetProtocol::NotValid, "Wrong HelpId!" );
38 return INET_HID_SCHEME + aTmp;
41 using namespace com::sun::star::uno;
42 using namespace com::sun::star;
43 using com::sun::star::inspection::PropertyCategoryDescriptor;
46 //= DefaultComponentInspectorModel
49 DefaultComponentInspectorModel::DefaultComponentInspectorModel( const Reference< XComponentContext >& _rxContext)
50 :m_xContext( _rxContext )
51 ,m_bConstructed( false )
52 ,m_bHasHelpSection( false )
53 ,m_bIsReadOnly(false)
54 ,m_nMinHelpTextLines( 3 )
55 ,m_nMaxHelpTextLines( 8 )
59 DefaultComponentInspectorModel::~DefaultComponentInspectorModel()
63 OUString SAL_CALL DefaultComponentInspectorModel::getImplementationName( )
65 return getImplementationName_Static();
68 sal_Bool SAL_CALL DefaultComponentInspectorModel::supportsService( const OUString& ServiceName )
70 return cppu::supportsService(this, ServiceName);
73 Sequence< OUString > SAL_CALL DefaultComponentInspectorModel::getSupportedServiceNames( )
75 return getSupportedServiceNames_static();
78 OUString DefaultComponentInspectorModel::getImplementationName_Static( )
80 return OUString("com.sun.star.comp.report.DefaultComponentInspectorModel");
83 Sequence< OUString > DefaultComponentInspectorModel::getSupportedServiceNames_static( )
85 Sequence< OUString > aSupported { "com.sun.star.report.inspection.DefaultComponentInspectorModel" };
86 return aSupported;
89 Reference< XInterface > DefaultComponentInspectorModel::create( const Reference< XComponentContext >& _rxContext )
91 return *(new DefaultComponentInspectorModel( _rxContext ));
95 Sequence< Any > SAL_CALL DefaultComponentInspectorModel::getHandlerFactories()
97 // service names for all our handlers
98 return Sequence<Any> {
99 Any(OUString( "com.sun.star.report.inspection.ReportComponentHandler")),
100 Any(OUString( "com.sun.star.form.inspection.EditPropertyHandler")),
101 Any(OUString( "com.sun.star.report.inspection.DataProviderHandler")),
102 Any(OUString( "com.sun.star.report.inspection.GeometryHandler"))
106 sal_Bool SAL_CALL DefaultComponentInspectorModel::getHasHelpSection()
108 ::osl::MutexGuard aGuard(m_aMutex);
109 return m_bHasHelpSection;
113 ::sal_Int32 SAL_CALL DefaultComponentInspectorModel::getMinHelpTextLines()
115 ::osl::MutexGuard aGuard(m_aMutex);
116 return m_nMinHelpTextLines;
119 sal_Bool SAL_CALL DefaultComponentInspectorModel::getIsReadOnly()
121 ::osl::MutexGuard aGuard(m_aMutex);
122 return m_bIsReadOnly;
125 void SAL_CALL DefaultComponentInspectorModel::setIsReadOnly( sal_Bool _isreadonly )
127 ::osl::MutexGuard aGuard(m_aMutex);
128 m_bIsReadOnly = _isreadonly;
132 ::sal_Int32 SAL_CALL DefaultComponentInspectorModel::getMaxHelpTextLines()
134 ::osl::MutexGuard aGuard(m_aMutex);
135 return m_nMaxHelpTextLines;
138 void SAL_CALL DefaultComponentInspectorModel::initialize( const Sequence< Any >& _arguments )
140 ::osl::MutexGuard aGuard(m_aMutex);
141 if ( m_bConstructed )
142 throw ucb::AlreadyInitializedException();
144 if ( !_arguments.hasElements() )
145 { // constructor: "createDefault()"
146 m_bConstructed = true;
147 return;
150 sal_Int32 nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
151 if ( _arguments.getLength() == 2 )
152 { // constructor: "createWithHelpSection( long, long )"
153 if ( !( _arguments[0] >>= nMinHelpTextLines ) || !( _arguments[1] >>= nMaxHelpTextLines ) )
154 throw lang::IllegalArgumentException( OUString(), *this, 0 );
155 createWithHelpSection( nMinHelpTextLines, nMaxHelpTextLines );
156 return;
159 throw lang::IllegalArgumentException( OUString(), *this, 0 );
163 void DefaultComponentInspectorModel::createWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
165 if ( ( _nMinHelpTextLines <= 0 ) || ( _nMaxHelpTextLines <= 0 ) || ( _nMinHelpTextLines > _nMaxHelpTextLines ) )
166 throw lang::IllegalArgumentException( OUString(), *this, 0 );
168 m_bHasHelpSection = true;
169 m_nMinHelpTextLines = _nMinHelpTextLines;
170 m_nMaxHelpTextLines = _nMaxHelpTextLines;
171 m_bConstructed = true;
174 Sequence< PropertyCategoryDescriptor > SAL_CALL DefaultComponentInspectorModel::describeCategories( )
176 ::osl::MutexGuard aGuard( m_aMutex );
178 const struct
180 const sal_Char* programmaticName;
181 const char* uiNameResId;
182 OString const helpId;
183 } aCategories[] = {
184 { "General", RID_STR_PROPPAGE_DEFAULT, HID_RPT_PROPDLG_TAB_GENERAL },
185 { "Data", RID_STR_PROPPAGE_DATA, HID_RPT_PROPDLG_TAB_DATA },
188 const size_t nCategories = SAL_N_ELEMENTS( aCategories );
189 Sequence< PropertyCategoryDescriptor > aReturn( nCategories );
190 PropertyCategoryDescriptor* pReturn = aReturn.getArray();
191 for ( size_t i=0; i<nCategories; ++i, ++pReturn )
193 pReturn->ProgrammaticName = OUString::createFromAscii( aCategories[i].programmaticName );
194 pReturn->UIName = RptResId( aCategories[i].uiNameResId );
195 pReturn->HelpURL = HelpIdUrl::getHelpURL( aCategories[i].helpId );
198 return aReturn;
202 ::sal_Int32 SAL_CALL DefaultComponentInspectorModel::getPropertyOrderIndex( const OUString& _rPropertyName )
204 ::osl::MutexGuard aGuard(m_aMutex);
205 const sal_Int32 nPropertyId( OPropertyInfoService::getPropertyId( _rPropertyName ) );
206 if ( nPropertyId != -1 )
207 return nPropertyId;
209 if ( !m_xComponent.is() )
212 m_xComponent.set(m_xContext->getServiceManager()->createInstanceWithContext("com.sun.star.form.inspection.DefaultFormComponentInspectorModel",m_xContext),UNO_QUERY_THROW);
214 catch(const Exception &)
216 return 0;
219 return m_xComponent->getPropertyOrderIndex(_rPropertyName);
223 } // namespace rptui
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */