summaryrefslogtreecommitdiff
path: root/forms/source/xforms/model_ui.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'forms/source/xforms/model_ui.cxx')
-rw-r--r--forms/source/xforms/model_ui.cxx112
1 files changed, 63 insertions, 49 deletions
diff --git a/forms/source/xforms/model_ui.cxx b/forms/source/xforms/model_ui.cxx
index 2ce182031579..5d56e8b3baa0 100644
--- a/forms/source/xforms/model_ui.cxx
+++ b/forms/source/xforms/model_ui.cxx
@@ -159,8 +159,7 @@ static void lcl_OutName( OUStringBuffer& rBuffer,
OUString sPrefix = xNode->getPrefix();
if( !sPrefix.isEmpty() )
{
- rBuffer.insert( 0, ':' );
- rBuffer.insert( 0, sPrefix );
+ rBuffer.insert( 0, sPrefix + ":" );
}
}
@@ -194,8 +193,7 @@ static void lcl_OutInstance( OUStringBuffer& rBuffer,
sInstanceName = sId;
}
- rBuffer.insert( 0, sInstanceName );
- rBuffer.insert( 0, "instance('" );
+ rBuffer.insert( 0, "instance('" + sInstanceName );
}
OUString Model::getDefaultBindingExpressionForNode(
@@ -287,7 +285,7 @@ OUString Model::getNodeDisplayName( const css::uno::Reference<css::xml::dom::XNo
OUString sContent = xNode->getNodeValue();
if( bDetail || ! lcl_isWhitespace( sContent ) )
{
- aBuffer.append("\"").append(Convert::collapseWhitespace( sContent )).append("\"");
+ aBuffer.append("\"" + Convert::collapseWhitespace( sContent ) + "\"");
}
}
break;
@@ -365,7 +363,7 @@ OUString Model::getSubmissionName( const css::uno::Reference< ::css::beans::XPro
css::uno::Reference< ::css::beans::XPropertySet > Model::cloneBindingAsGhost( const css::uno::Reference< ::css::beans::XPropertySet > &xBinding )
{
// Create a new binding instance first...
- Binding *pBinding = new Binding();
+ rtl::Reference<Binding> pBinding = new Binding();
// ...and bump up the "deferred notification counter"
// to prevent this binding from contributing to the
@@ -380,7 +378,7 @@ css::uno::Reference< ::css::beans::XPropertySet > Model::cloneBindingAsGhost( co
void Model::removeBindingIfUseless( const css::uno::Reference< ::css::beans::XPropertySet >& xBinding )
{
- Binding* pBinding = comphelper::getUnoTunnelImplementation<Binding>( xBinding );
+ Binding* pBinding = comphelper::getFromUnoTunnel<Binding>( xBinding );
if( pBinding != nullptr )
{
if( ! pBinding->isUseful() )
@@ -504,13 +502,13 @@ css::uno::Reference<css::xforms::XModel> Model::newModel( const Reference<css::f
if( xModels.is()
&& ! xModels->hasByName( sName ) )
{
- Model* pModel = new Model();
+ rtl::Reference<Model> pModel = new Model();
xModel.set( pModel );
pModel->setID( sName );
pModel->newInstance( OUString(), OUString(), false );
pModel->initialize();
- xModels->insertByName( sName, makeAny( xModel ) );
+ xModels->insertByName( sName, Any( xModel ) );
}
return xModel;
@@ -527,7 +525,7 @@ void Model::renameModel( const Reference<css::frame::XModel>& xCmp,
{
Reference<XModel> xModel( xModels->getByName( sFrom ), UNO_QUERY );
xModel->setID( sTo );
- xModels->insertByName( sTo, makeAny( xModel ) );
+ xModels->insertByName( sTo, Any( xModel ) );
xModels->removeByName( sFrom );
}
}
@@ -610,6 +608,8 @@ css::uno::Reference<css::xml::dom::XNode> Model::renameNode( const css::uno::Ref
Reference<XNamedNodeMap> xMap = xNode->getAttributes();
sal_Int32 nLength = xMap.is() ? xMap->getLength() : 0;
+ // looping until nLength is suspicious wrt removeAttributeNode
+ // presumably shrinking XNamedNodeMap::getLength by 1
for( sal_Int32 n = 0; n < nLength; n++ )
{
Reference<XAttr> xAttr( xMap->item(n), UNO_QUERY );
@@ -650,7 +650,7 @@ css::uno::Reference<css::xml::dom::XNode> Model::renameNode( const css::uno::Ref
getDefaultBindingExpressionForNode( xNew );
for( sal_Int32 n = 0; n < mxBindings->countItems(); n++ )
{
- Binding* pBinding = comphelper::getUnoTunnelImplementation<Binding>(
+ Binding* pBinding = comphelper::getFromUnoTunnel<Binding>(
mxBindings->Collection<XPropertySet_t>::getItem( n ) );
if( pBinding->getBindingExpression()
@@ -672,12 +672,12 @@ css::uno::Reference< ::css::beans::XPropertySet > Model::getBindingForNode( cons
// appropriateness of the respective binding for this node. The
// best one will be used. If we don't find any and bCreate is set,
// then we will create a suitable binding.
- Binding* pBestBinding = nullptr;
+ rtl::Reference<Binding> pBestBinding;
sal_Int32 nBestScore = 0;
for( sal_Int32 n = 0; n < mxBindings->countItems(); n++ )
{
- Binding* pBinding = comphelper::getUnoTunnelImplementation<Binding>(
+ Binding* pBinding = comphelper::getFromUnoTunnel<Binding>(
mxBindings->Collection<XPropertySet_t>::getItem( n ) );
OSL_ENSURE( pBinding != nullptr, "no binding?" );
@@ -814,8 +814,7 @@ static OUString lcl_serializeForDisplay( const Reference<XNodeList>& xNodes )
if( !sLine.isEmpty()
&& !sLine.startsWith( "<?xml" ) )
{
- sResult.append( sLine );
- sResult.append( '\n' );
+ sResult.append( sLine + "\n" );
}
}
@@ -860,7 +859,7 @@ OUString Model::getResultForExpression(
sal_Bool bIsBindingExpression,
const OUString& sExpression )
{
- Binding* pBinding = comphelper::getUnoTunnelImplementation<Binding>( xBinding );
+ Binding* pBinding = comphelper::getFromUnoTunnel<Binding>( xBinding );
if( pBinding == nullptr )
throw RuntimeException();
@@ -922,15 +921,14 @@ void xforms::getInstanceData(
for( sal_Int32 n = 0; n < nValues; n++ )
{
const PropertyValue& rValue = pValues[n];
-#define PROP(NAME) \
- if( p##NAME != nullptr && \
- rValue.Name == #NAME ) \
- rValue.Value >>= (*p##NAME)
- PROP(ID);
- PROP(Instance);
- PROP(URL);
- PROP(URLOnce);
-#undef PROP
+ if( pID != nullptr && rValue.Name == "ID")
+ rValue.Value >>= *pID;
+ if( pInstance != nullptr && rValue.Name == "Instance")
+ rValue.Value >>= *pInstance;
+ if( pURL != nullptr && rValue.Name == "URL")
+ rValue.Value >>= *pURL;
+ if( pURLOnce != nullptr && rValue.Name == "URLOnce")
+ rValue.Value >>= *pURLOnce;
}
}
@@ -953,38 +951,54 @@ void xforms::setInstanceData(
const bool* pURLOnce = ( bURLOnce && pURL != nullptr ) ? &bURLOnce : nullptr;
// determine new instance data
-#define PROP(NAME) if( _p##NAME != nullptr ) p##NAME = _p##NAME
- PROP(ID);
- PROP(Instance);
- PROP(URL);
- PROP(URLOnce);
-#undef PROP
+ if (_pID != nullptr)
+ pID = _pID;
+ if (_pInstance != nullptr)
+ pInstance = _pInstance;
+ if (_pURL != nullptr)
+ pURL = _pURL;
+ if (_pURLOnce != nullptr)
+ pURLOnce = _pURLOnce;
// count # of values we want to set
sal_Int32 nCount = 0;
-#define PROP(NAME) if( p##NAME != nullptr ) nCount++
- PROP(ID);
- PROP(Instance);
- PROP(URL);
- PROP(URLOnce);
-#undef PROP
+ if (pID != nullptr)
+ ++nCount;
+ if (pInstance != nullptr)
+ ++nCount;
+ if (pURL != nullptr)
+ ++nCount;
+ if (pURLOnce != nullptr)
+ ++nCount;
// realloc sequence and enter values;
aSequence.realloc( nCount );
PropertyValue* pSequence = aSequence.getArray();
sal_Int32 nIndex = 0;
-#define PROP(NAME) \
- if( p##NAME != nullptr ) \
- { \
- pSequence[ nIndex ].Name = #NAME; \
- pSequence[ nIndex ].Value <<= *p##NAME; \
- nIndex++; \
- }
- PROP(ID);
- PROP(Instance);
- PROP(URL);
- PROP(URLOnce);
-#undef PROP
+ if(pID != nullptr)
+ {
+ pSequence[ nIndex ].Name = "ID";
+ pSequence[ nIndex ].Value <<= *pID;
+ nIndex++;
+ }
+ if(pInstance != nullptr)
+ {
+ pSequence[ nIndex ].Name = "Instance";
+ pSequence[ nIndex ].Value <<= *pInstance;
+ nIndex++;
+ }
+ if(pURL != nullptr)
+ {
+ pSequence[ nIndex ].Name = "URL";
+ pSequence[ nIndex ].Value <<= *pURL;
+ nIndex++;
+ }
+ if(pURLOnce != nullptr)
+ {
+ pSequence[ nIndex ].Name = "URLOnce";
+ pSequence[ nIndex ].Value <<= *pURLOnce;
+ nIndex++;
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */