diff options
Diffstat (limited to 'forms/source/component/DatabaseForm.cxx')
-rw-r--r-- | forms/source/component/DatabaseForm.cxx | 95 |
1 files changed, 45 insertions, 50 deletions
diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index 6ba5a380ee9c..4bad0608b5bc 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -29,6 +29,7 @@ #include "GroupManager.hxx" #include <property.hxx> #include <services.hxx> +#include <comphelper/propertyvalue.hxx> #include <com/sun/star/awt/XControlContainer.hpp> #include <com/sun/star/awt/XTextComponent.hpp> @@ -68,7 +69,7 @@ #include <svl/inettype.hxx> #include <tools/datetime.hxx> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <tools/inetmsg.hxx> #include <tools/inetstrm.hxx> #include <tools/urlobj.hxx> @@ -436,9 +437,7 @@ OUString ODatabaseForm::GetDataEncoded(bool _bURLEncoded,const Reference<XContro Encode( aName ); Encode( aValue ); - aResult.append(aName); - aResult.append('='); - aResult.append(aValue); + aResult.append(aName + "=" + aValue); if (pSuccObj < aSuccObjList.end() - 1) { @@ -904,9 +903,9 @@ void ODatabaseForm::Encode( OUString& rString ) short nLo = static_cast<sal_Int16>(nCharCode) - (nHi*16); if( nHi > 9 ) nHi += int('A')-10; else nHi += int('0'); if( nLo > 9 ) nLo += int('A')-10; else nLo += int('0'); - aResult.append('%'); - aResult.append(static_cast<sal_Unicode>(nHi)); - aResult.append(static_cast<sal_Unicode>(nLo)); + aResult.append("%" + + OUStringChar(static_cast<sal_Unicode>(nHi)) + + OUStringChar(static_cast<sal_Unicode>(nLo)) ); } } } @@ -939,11 +938,11 @@ void ODatabaseForm::InsertTextPart( INetMIMEMessage& rParent, std::u16string_vie pChild->SetContentTransferEncoding("8bit"); // Body - SvMemoryStream* pStream = new SvMemoryStream; + std::unique_ptr<SvMemoryStream> pStream(new SvMemoryStream); pStream->WriteLine( OUStringToOString(rData, rtl_getTextEncodingFromMimeCharset(pBestMatchingEncoding)) ); pStream->FlushBuffer(); pStream->Seek( 0 ); - pChild->SetDocumentLB( new SvLockBytes(pStream, true) ); + pChild->SetDocumentLB( std::move(pStream) ); rParent.AttachChild( std::move(pChild) ); } @@ -1002,7 +1001,7 @@ void ODatabaseForm::InsertFilePart( INetMIMEMessage& rParent, std::u16string_vie // Body - pChild->SetDocumentLB( new SvLockBytes(pStream.release(), true) ); + pChild->SetDocumentLB( std::move(pStream) ); rParent.AttachChild( std::move(pChild) ); } @@ -1020,7 +1019,7 @@ void ODatabaseForm::onError( const SQLException& _rException, const OUString& _r if ( !m_aErrorListeners.getLength() ) return; - SQLErrorEvent aEvent( *this, makeAny( prependErrorInfo( _rException, *this, _rContextDescription ) ) ); + SQLErrorEvent aEvent( *this, Any( prependErrorInfo( _rException, *this, _rContextDescription ) ) ); onError( aEvent ); } @@ -1126,15 +1125,15 @@ bool ODatabaseForm::executeRowSet(::osl::ResettableMutexGuard& _rClearForNotifie // switch to "insert only" mode saveInsertOnlyState( ); - m_xAggregateSet->setPropertyValue( PROPERTY_INSERTONLY, makeAny( true ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_INSERTONLY, Any( true ) ); } else if (m_bAllowInsert || m_bAllowUpdate || m_bAllowDelete) nConcurrency = ResultSetConcurrency::UPDATABLE; else nConcurrency = ResultSetConcurrency::READ_ONLY; - m_xAggregateSet->setPropertyValue( PROPERTY_RESULTSET_CONCURRENCY, makeAny( nConcurrency ) ); - m_xAggregateSet->setPropertyValue( PROPERTY_RESULTSET_TYPE, makeAny( sal_Int32(ResultSetType::SCROLL_SENSITIVE) ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_RESULTSET_CONCURRENCY, Any( nConcurrency ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_RESULTSET_TYPE, Any( sal_Int32(ResultSetType::SCROLL_SENSITIVE) ) ); bool bSuccess = false; try @@ -1327,7 +1326,7 @@ void ODatabaseForm::describeFixedAndAggregateProperties( Reference< XMultiPropertySet > ODatabaseForm::getPropertiesInterface() { - return Reference< XMultiPropertySet >( *this, UNO_QUERY ); + return this; } @@ -1615,7 +1614,7 @@ void ODatabaseForm::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const A if ( m_aIgnoreResult.hasValue() ) m_aIgnoreResult <<= m_bInsertOnly; else - m_xAggregateSet->setPropertyValue( PROPERTY_INSERTONLY, makeAny( m_bInsertOnly ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_INSERTONLY, Any( m_bInsertOnly ) ); break; case PROPERTY_ID_FILTER: @@ -1954,7 +1953,7 @@ void ODatabaseForm::reset_impl(bool _bApproveByListeners) if ( xColProps.is() ) xPSI = xColProps->getPropertySetInfo( ); - static constexpr OUStringLiteral PROPERTY_CONTROLDEFAULT = u"ControlDefault"; + static constexpr OUString PROPERTY_CONTROLDEFAULT = u"ControlDefault"_ustr; if ( xPSI.is() && xPSI->hasPropertyByName( PROPERTY_CONTROLDEFAULT ) ) { Any aDefault = xColProps->getPropertyValue( PROPERTY_CONTROLDEFAULT ); @@ -2103,9 +2102,6 @@ static void lcl_dispatch(const Reference< XFrame >& xFrame,const Reference<XURLT if (!xDisp.is()) return; - Sequence<PropertyValue> aArgs(2); - aArgs.getArray()[0].Name = "Referer"; - aArgs.getArray()[0].Value <<= aReferer; // build a sequence from the to-be-submitted string OString a8BitData(OUStringToOString(aData, _eEncoding)); @@ -2113,8 +2109,11 @@ static void lcl_dispatch(const Reference< XFrame >& xFrame,const Reference<XURLT Sequence< sal_Int8 > aPostData(reinterpret_cast<const sal_Int8*>(a8BitData.getStr()), a8BitData.getLength()); Reference< XInputStream > xPostData = new SequenceInputStream(aPostData); - aArgs.getArray()[1].Name = "PostData"; - aArgs.getArray()[1].Value <<= xPostData; + Sequence<PropertyValue> aArgs + { + comphelper::makePropertyValue("Referer", aReferer), + comphelper::makePropertyValue("PostData", xPostData) + }; xDisp->dispatch(aURL, aArgs); } @@ -2193,9 +2192,7 @@ void ODatabaseForm::submit_impl(const Reference<XControl>& Control, const css::a if (xDisp.is()) { - Sequence<PropertyValue> aArgs(1); - aArgs.getArray()->Name = "Referer"; - aArgs.getArray()->Value <<= aReferer; + Sequence<PropertyValue> aArgs { comphelper::makePropertyValue("Referer", aReferer) }; xDisp->dispatch(aURL, aArgs); } } @@ -2226,17 +2223,15 @@ void ODatabaseForm::submit_impl(const Reference<XControl>& Control, const css::a if (!aData.hasElements()) return; - Sequence<PropertyValue> aArgs(3); - aArgs.getArray()[0].Name = "Referer"; - aArgs.getArray()[0].Value <<= aReferer; - aArgs.getArray()[1].Name = "ContentType"; - aArgs.getArray()[1].Value <<= aContentType; - // build a sequence from the to-be-submitted string Reference< XInputStream > xPostData = new SequenceInputStream(aData); - aArgs.getArray()[2].Name = "PostData"; - aArgs.getArray()[2].Value <<= xPostData; + Sequence<PropertyValue> aArgs + { + comphelper::makePropertyValue("Referer", aReferer), + comphelper::makePropertyValue("ContentType", aContentType), + comphelper::makePropertyValue("PostData", xPostData) + }; xDisp->dispatch(aURL, aArgs); } @@ -2368,7 +2363,7 @@ void SAL_CALL ODatabaseForm::setParent(const css::uno::Reference<css::uno::XInte bool bIsEmbedded = ::dbtools::isEmbeddedInDatabase( Parent, xOuterConnection ); if ( bIsEmbedded ) - xAggregateProperties->setPropertyValue( PROPERTY_DATASOURCE, makeAny( OUString() ) ); + xAggregateProperties->setPropertyValue( PROPERTY_DATASOURCE, Any( OUString() ) ); } @@ -2419,7 +2414,7 @@ void SAL_CALL ODatabaseForm::setControlModels(const Sequence<Reference<XControlM { Reference<XPropertySet> xSet(xComp, UNO_QUERY); if (xSet.is() && hasProperty(PROPERTY_TABINDEX, xSet)) - xSet->setPropertyValue( PROPERTY_TABINDEX, makeAny(nTabIndex++) ); + xSet->setPropertyValue( PROPERTY_TABINDEX, Any(nTabIndex++) ); break; } } @@ -2458,7 +2453,7 @@ void SAL_CALL ODatabaseForm::setGroup( const Sequence<Reference<XControlModel> > if (sGroupName.isEmpty()) xSet->getPropertyValue(PROPERTY_NAME) >>= sGroupName; else - xSet->setPropertyValue(PROPERTY_NAME, makeAny(sGroupName)); + xSet->setPropertyValue(PROPERTY_NAME, Any(sGroupName)); } } @@ -2681,7 +2676,7 @@ void ODatabaseForm::doShareConnection( const Reference< XPropertySet >& _rxParen // forward the connection to our own aggregate m_bForwardingConnection = true; - m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xParentConn ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, Any( xParentConn ) ); m_bForwardingConnection = false; m_bSharingConnection = true; @@ -2723,7 +2718,7 @@ void ODatabaseForm::stopSharingConnection( ) // reset the property xSharedConn.clear(); m_bForwardingConnection = true; - m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xSharedConn ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, Any( xSharedConn ) ); m_bForwardingConnection = false; // reset the flag @@ -2758,7 +2753,7 @@ bool ODatabaseForm::implEnsureConnection() Reference< XConnection > xOuterConnection; if ( ::dbtools::isEmbeddedInDatabase( getParent(), xOuterConnection ) ) { - m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xOuterConnection ) ); + m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, Any( xOuterConnection ) ); return xOuterConnection.is(); } @@ -2832,7 +2827,7 @@ void ODatabaseForm::load_impl(bool bCausedByParentForm, bool bMoveToFirst, const // a database form always uses caching // we use starting fetchsize with at least 10 rows if (bConnected) - m_xAggregateSet->setPropertyValue(PROPERTY_FETCHSIZE, makeAny(sal_Int32(40))); + m_xAggregateSet->setPropertyValue(PROPERTY_FETCHSIZE, Any(sal_Int32(40))); // if we're loaded as sub form we got a "rowSetChanged" from the parent rowset _before_ we got the "loaded" // so we don't need to execute the statement again, this was already done @@ -3884,10 +3879,10 @@ void SAL_CALL ODatabaseForm::read(const Reference<XObjectInputStream>& _rxInStre OUString sAggregateProp; _rxInStream >> sAggregateProp; if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_DATASOURCE, makeAny(sAggregateProp)); + m_xAggregateSet->setPropertyValue(PROPERTY_DATASOURCE, Any(sAggregateProp)); _rxInStream >> sAggregateProp; if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_COMMAND, makeAny(sAggregateProp)); + m_xAggregateSet->setPropertyValue(PROPERTY_COMMAND, Any(sAggregateProp)); _rxInStream >> m_aMasterFields; _rxInStream >> m_aDetailFields; @@ -3903,13 +3898,13 @@ void SAL_CALL ODatabaseForm::read(const Reference<XObjectInputStream>& _rxInStre { nCommandType = CommandType::COMMAND; bool bEscapeProcessing = static_cast<DataSelectionType>(nCursorSourceType) != DataSelectionType_SQLPASSTHROUGH; - m_xAggregateSet->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, makeAny(bEscapeProcessing)); + m_xAggregateSet->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, Any(bEscapeProcessing)); } break; default : OSL_FAIL("ODatabaseForm::read : wrong CommandType !"); } if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_COMMANDTYPE, makeAny(nCommandType)); + m_xAggregateSet->setPropertyValue(PROPERTY_COMMANDTYPE, Any(nCommandType)); // obsolete _rxInStream->readShort(); @@ -3922,7 +3917,7 @@ void SAL_CALL ODatabaseForm::read(const Reference<XObjectInputStream>& _rxInStre bool bInsertOnly = _rxInStream->readBoolean(); if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_INSERTONLY, makeAny(bInsertOnly)); + m_xAggregateSet->setPropertyValue(PROPERTY_INSERTONLY, Any(bInsertOnly)); m_bAllowInsert = _rxInStream->readBoolean(); m_bAllowUpdate = _rxInStream->readBoolean(); @@ -3944,12 +3939,12 @@ void SAL_CALL ODatabaseForm::read(const Reference<XObjectInputStream>& _rxInStre _rxInStream >> sAggregateProp; if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_FILTER, makeAny(sAggregateProp)); + m_xAggregateSet->setPropertyValue(PROPERTY_FILTER, Any(sAggregateProp)); if(nVersion > 3) { _rxInStream >> sAggregateProp; if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_SORT, makeAny(sAggregateProp)); + m_xAggregateSet->setPropertyValue(PROPERTY_SORT, Any(sAggregateProp)); } } @@ -3966,13 +3961,13 @@ void SAL_CALL ODatabaseForm::read(const Reference<XObjectInputStream>& _rxInStre m_aCycle.clear(); } if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_APPLYFILTER, makeAny((nAnyMask & DONTAPPLYFILTER) == 0)); + m_xAggregateSet->setPropertyValue(PROPERTY_APPLYFILTER, Any((nAnyMask & DONTAPPLYFILTER) == 0)); if(nVersion > 4) { _rxInStream >> sAggregateProp; if (m_xAggregateSet.is()) - m_xAggregateSet->setPropertyValue(PROPERTY_HAVINGCLAUSE, makeAny(sAggregateProp)); + m_xAggregateSet->setPropertyValue(PROPERTY_HAVINGCLAUSE, Any(sAggregateProp)); } } @@ -4032,7 +4027,7 @@ OUString SAL_CALL ODatabaseForm::getName() void SAL_CALL ODatabaseForm::setName(const OUString& aName) { - setFastPropertyValue(PROPERTY_ID_NAME, makeAny(aName)); + setFastPropertyValue(PROPERTY_ID_NAME, Any(aName)); } } // namespace frm |