diff options
-rw-r--r-- | cui/source/options/optjava.cxx | 77 | ||||
-rw-r--r-- | cui/source/options/optjava.hxx | 7 | ||||
-rw-r--r-- | include/jvmfwk/framework.hxx | 19 | ||||
-rw-r--r-- | jvmfwk/inc/elements.hxx | 7 | ||||
-rw-r--r-- | jvmfwk/source/elements.cxx | 37 | ||||
-rw-r--r-- | jvmfwk/source/framework.cxx | 10 |
6 files changed, 33 insertions, 124 deletions
diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx index 84c9fef6ca1b..03a2c6232d83 100644 --- a/cui/source/options/optjava.cxx +++ b/cui/source/options/optjava.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <vector> + #include <config_features.h> #include "optaboutconfig.hxx" @@ -63,35 +67,6 @@ using namespace ::com::sun::star::ucb; using namespace ::com::sun::star::ui::dialogs; using namespace ::com::sun::star::uno; -#if HAVE_FEATURE_JAVA - -static bool areListsEqual( const Sequence< OUString >& rListA, const Sequence< OUString >& rListB ) -{ - bool bRet = true; - const sal_Int32 nLen = rListA.getLength(); - - if ( rListB.getLength() != nLen ) - bRet = false; - else - { - const OUString* pStringA = rListA.getConstArray(); - const OUString* pStringB = rListB.getConstArray(); - - for ( sal_Int32 i = 0; i < nLen; ++i ) - { - if ( *pStringA++ != *pStringB++ ) - { - bRet = false; - break; - } - } - } - - return bRet; -} - -#endif - class SvxJavaListBox : public svx::SvxRadioButtonListBox { private: @@ -138,10 +113,6 @@ SvxJavaOptionsPage::SvxJavaOptionsPage( vcl::Window* pParent, const SfxItemSet& : SfxTabPage(pParent, "OptAdvancedPage", "cui/ui/optadvancedpage.ui", &rSet) , m_pParamDlg(nullptr) , m_pPathDlg(nullptr) -#if HAVE_FEATURE_JAVA - , m_parParameters(nullptr) - , m_nParamSize(0) -#endif , m_aResetIdle("cui options SvxJavaOptionsPage Reset") , xDialogListener(new ::svt::DialogClosedListener()) { @@ -293,21 +264,14 @@ IMPL_LINK_NOARG(SvxJavaOptionsPage, AddHdl_Impl, Button*, void) IMPL_LINK_NOARG(SvxJavaOptionsPage, ParameterHdl_Impl, Button*, void) { #if HAVE_FEATURE_JAVA - Sequence< OUString > aParameterList; + std::vector< OUString > aParameterList; if ( !m_pParamDlg ) { m_pParamDlg = VclPtr<SvxJavaParameterDlg>::Create( this ); - javaFrameworkError eErr = jfw_getVMParameters( &m_parParameters, &m_nParamSize ); - if ( JFW_E_NONE == eErr && m_parParameters && m_nParamSize > 0 ) + javaFrameworkError eErr = jfw_getVMParameters( &m_parParameters ); + if ( JFW_E_NONE == eErr && !m_parParameters.empty() ) { - rtl_uString** pParamArr = m_parParameters; - aParameterList.realloc( m_nParamSize ); - OUString* pParams = aParameterList.getArray(); - for ( sal_Int32 i = 0; i < m_nParamSize; ++i ) - { - rtl_uString* pParam = *pParamArr++; - pParams[i] = OUString( pParam ); - } + aParameterList = m_parParameters; m_pParamDlg->SetParameters( aParameterList ); } } @@ -319,7 +283,7 @@ IMPL_LINK_NOARG(SvxJavaOptionsPage, ParameterHdl_Impl, Button*, void) if ( m_pParamDlg->Execute() == RET_OK ) { - if ( !areListsEqual( aParameterList, m_pParamDlg->GetParameters() ) ) + if ( aParameterList != m_pParamDlg->GetParameters() ) { aParameterList = m_pParamDlg->GetParameters(); if ( jfw_isVMRunning() ) @@ -632,15 +596,8 @@ bool SvxJavaOptionsPage::FillItemSet( SfxItemSet* /*rCoreSet*/ ) javaFrameworkError eErr = JFW_E_NONE; if ( m_pParamDlg ) { - Sequence< OUString > aParamList = m_pParamDlg->GetParameters(); - sal_Int32 i, nSize = aParamList.getLength(); - rtl_uString** pParamArr = static_cast<rtl_uString**>(rtl_allocateMemory( sizeof(rtl_uString*) * nSize )); - const OUString* pList = aParamList.getConstArray(); - for ( i = 0; i < nSize; ++i ) - pParamArr[i] = pList[i].pData; - eErr = jfw_setVMParameters( pParamArr, nSize ); + eErr = jfw_setVMParameters( m_pParamDlg->GetParameters() ); SAL_WARN_IF(JFW_E_NONE != eErr, "cui.options", "SvxJavaOptionsPage::FillItemSet(): error in jfw_setVMParameters"); - rtl_freeMemory( pParamArr ); bModified = true; } @@ -879,13 +836,12 @@ short SvxJavaParameterDlg::Execute() } -Sequence< OUString > SvxJavaParameterDlg::GetParameters() const +std::vector< OUString > SvxJavaParameterDlg::GetParameters() const { sal_Int32 nCount = m_pAssignedList->GetEntryCount(); - Sequence< OUString > aParamList( nCount ); - OUString* pArray = aParamList.getArray(); + std::vector< OUString > aParamList; for ( sal_Int32 i = 0; i < nCount; ++i ) - pArray[i] = OUString( m_pAssignedList->GetEntry(i) ); + aParamList.push_back( m_pAssignedList->GetEntry(i) ); return aParamList; } @@ -897,14 +853,11 @@ void SvxJavaParameterDlg::DisableButtons() DisableRemoveButton(); } -void SvxJavaParameterDlg::SetParameters( Sequence< OUString >& rParams ) +void SvxJavaParameterDlg::SetParameters( std::vector< OUString > const & rParams ) { m_pAssignedList->Clear(); - sal_uLong i, nCount = rParams.getLength(); - const OUString* pArray = rParams.getConstArray(); - for ( i = 0; i < nCount; ++i ) + for (auto const & sParam: rParams) { - OUString sParam = OUString( *pArray++ ); m_pAssignedList->InsertEntry( sParam ); } DisableEditButton(); diff --git a/cui/source/options/optjava.hxx b/cui/source/options/optjava.hxx index 47fb0a85e32c..6598dfda5c70 100644 --- a/cui/source/options/optjava.hxx +++ b/cui/source/options/optjava.hxx @@ -66,9 +66,8 @@ private: #if HAVE_FEATURE_JAVA std::vector<std::unique_ptr<JavaInfo>> m_parJavaInfo; - rtl_uString** m_parParameters; + std::vector<OUString> m_parParameters; OUString m_pClassPath; - sal_Int32 m_nParamSize; #endif OUString m_sInstallText; OUString m_sAccessibilityText; @@ -165,8 +164,8 @@ public: virtual short Execute() override; - css::uno::Sequence< OUString > GetParameters() const; - void SetParameters( css::uno::Sequence< OUString >& rParams ); + std::vector< OUString > GetParameters() const; + void SetParameters( std::vector< OUString > const & rParams ); void DisableButtons(); void EditParameter(); }; diff --git a/include/jvmfwk/framework.hxx b/include/jvmfwk/framework.hxx index c0aff6841682..d6059bb640af 100644 --- a/include/jvmfwk/framework.hxx +++ b/include/jvmfwk/framework.hxx @@ -29,7 +29,6 @@ #include <jvmfwk/jvmfwkdllapi.hxx> #include <rtl/byteseq.hxx> -#include <rtl/ustring.h> #include <rtl/ustring.hxx> #include <osl/mutex.h> #include "jni.h" @@ -587,9 +586,7 @@ JVMFWK_DLLPUBLIC javaFrameworkError jfw_getEnabled(bool *pbEnabled); </p> @param arParameters - [in] contains the arguments. It can be NULL if nSize is 0. - @param nSize - [i] the size of <code>arArgs</code> + [in] contains the arguments. @return JFW_E_NONE function ran successfully.<br/> @@ -599,21 +596,12 @@ JVMFWK_DLLPUBLIC javaFrameworkError jfw_getEnabled(bool *pbEnabled); JFW_E_DIRECT_MODE the function cannot be used in this mode. */ JVMFWK_DLLPUBLIC javaFrameworkError jfw_setVMParameters( - rtl_uString ** arArgs, sal_Int32 nSize); + std::vector<OUString> const & arArgs); /** obtains the currently used start parameters. - <p>The caller needs to free the returned array with - <code>rtl_freeMemory</code>. The contained strings must be released with - <code>rtl_uString_release</code>. - </p> - @param parParameters [out] on returns contains a pointer to the array of the start arguments. - If *parParameters is not NULL then the value is overwritten. - @param pSize - [out] on return contains the size of array returned in - <code>parParameters</code> @return JFW_E_NONE function ran successfully.<br/> @@ -623,8 +611,7 @@ JVMFWK_DLLPUBLIC javaFrameworkError jfw_setVMParameters( JFW_E_DIRECT_MODE the function cannot be used in this mode. */ JVMFWK_DLLPUBLIC javaFrameworkError jfw_getVMParameters( - rtl_uString *** parParameters, - sal_Int32 * pSize); + std::vector<OUString> * parParameters); /** sets the user class path. diff --git a/jvmfwk/inc/elements.hxx b/jvmfwk/inc/elements.hxx index f99861a83051..f4766a5c92bd 100644 --- a/jvmfwk/inc/elements.hxx +++ b/jvmfwk/inc/elements.hxx @@ -205,7 +205,7 @@ public: /java/vmParameters@xsi:nil will be set to true when write() is called. */ - void setVmParameters(rtl_uString * * arParameters, sal_Int32 size); + void setVmParameters(std::vector<OUString> const & arParameters); /** adds a location to the already existing locations. Note: call load() before, then add the location and then call write(). @@ -309,10 +309,7 @@ public: bool getJavaInfoAttrAutoSelect() const; #endif - /** returns an array. - Caller must free the strings and the array. - */ - void getVmParametersArray(rtl_uString *** parParameters, sal_Int32 * size) const; + void getVmParametersArray(std::vector<OUString> * parParameters) const; const ::std::vector< OUString> & getJRELocations() const { return m_JRELocations;} }; diff --git a/jvmfwk/source/elements.cxx b/jvmfwk/source/elements.cxx index b25c49f07104..4da38c001ed9 100644 --- a/jvmfwk/source/elements.cxx +++ b/jvmfwk/source/elements.cxx @@ -591,21 +591,9 @@ void NodeJava::setJavaInfo(const JavaInfo * pInfo, bool bAutoSelect) } } -void NodeJava::setVmParameters(rtl_uString * * arOptions, sal_Int32 size) +void NodeJava::setVmParameters(std::vector<OUString> const & arOptions) { - assert( !(arOptions == nullptr && size != 0)); - if ( ! m_vmParameters) - m_vmParameters = boost::optional<std::vector<OUString> >( - std::vector<OUString>()); - m_vmParameters->clear(); - if (arOptions != nullptr) - { - for (int i = 0; i < size; i++) - { - const OUString sOption(arOptions[i]); - m_vmParameters->push_back(sOption); - } - } + m_vmParameters = boost::optional<std::vector<OUString> >(arOptions); } void NodeJava::addJRELocation(OUString const & sLocation) @@ -1024,26 +1012,13 @@ bool MergedSettings::getJavaInfoAttrAutoSelect() const return m_javaInfo.bAutoSelect; } #endif -void MergedSettings::getVmParametersArray( - rtl_uString *** parParams, sal_Int32 * size) const +void MergedSettings::getVmParametersArray(std::vector<OUString> * parParams) + const { - assert(parParams != nullptr && size != nullptr); + assert(parParams != nullptr); osl::MutexGuard guard(FwkMutex::get()); - *parParams = static_cast<rtl_uString **>( - rtl_allocateMemory(sizeof(rtl_uString*) * m_vmParams.size())); - if (*parParams == nullptr) - return; - - int j=0; - typedef std::vector<OUString>::const_iterator it; - for (it i = m_vmParams.begin(); i != m_vmParams.end(); - ++i, ++j) - { - (*parParams)[j] = i->pData; - rtl_uString_acquire(i->pData); - } - *size = m_vmParams.size(); + *parParams = m_vmParams; } } diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx index 99b3e5e329dd..dda5b3e8aefe 100644 --- a/jvmfwk/source/framework.cxx +++ b/jvmfwk/source/framework.cxx @@ -834,8 +834,7 @@ javaFrameworkError jfw_getEnabled(bool *pbEnabled) } -javaFrameworkError jfw_setVMParameters( - rtl_uString * * arOptions, sal_Int32 nLen) +javaFrameworkError jfw_setVMParameters(std::vector<OUString> const & arOptions) { javaFrameworkError errcode = JFW_E_NONE; try @@ -844,7 +843,7 @@ javaFrameworkError jfw_setVMParameters( if (jfw::getMode() == jfw::JFW_MODE_DIRECT) return JFW_E_DIRECT_MODE; jfw::NodeJava node(jfw::NodeJava::USER); - node.setVmParameters(arOptions, nLen); + node.setVmParameters(arOptions); node.write(); } catch (const jfw::FrameworkException& e) @@ -857,8 +856,7 @@ javaFrameworkError jfw_setVMParameters( return errcode; } -javaFrameworkError jfw_getVMParameters( - rtl_uString *** parOptions, sal_Int32 * pLen) +javaFrameworkError jfw_getVMParameters(std::vector<OUString> * parOptions) { javaFrameworkError errcode = JFW_E_NONE; try @@ -868,7 +866,7 @@ javaFrameworkError jfw_getVMParameters( return JFW_E_DIRECT_MODE; const jfw::MergedSettings settings; - settings.getVmParametersArray(parOptions, pLen); + settings.getVmParametersArray(parOptions); } catch (const jfw::FrameworkException& e) { |