Skip to content
Permalink
Browse files
[FEATURE] @layout_name variable for retrieving composition name
Likely useful in some circumstances!

Fixes #15824
  • Loading branch information
nyalldawson committed Mar 15, 2017
1 parent ae45d8d commit 29a8c0cf171ec94d988914876fbca5c4a559bb94
Showing with 2 additions and 0 deletions.
  1. +1 −0 src/core/qgsexpression.cpp
  2. +1 −0 src/core/qgsexpressioncontext.cpp
@@ -5836,6 +5836,7 @@ void QgsExpression::initVariableHelp()
sVariableHelpTexts.insert( QStringLiteral( "layer" ), QCoreApplication::translate( "variable_help", "The current layer." ) );

//composition variables
sVariableHelpTexts.insert( QStringLiteral( "layout_name" ), QCoreApplication::translate( "variable_help", "Name of composition." ) );
sVariableHelpTexts.insert( QStringLiteral( "layout_numpages" ), QCoreApplication::translate( "variable_help", "Number of pages in composition." ) );
sVariableHelpTexts.insert( QStringLiteral( "layout_page" ), QCoreApplication::translate( "variable_help", "Current page number in composition." ) );
sVariableHelpTexts.insert( QStringLiteral( "layout_pageheight" ), QCoreApplication::translate( "variable_help", "Composition page height in mm." ) );
@@ -910,6 +910,7 @@ QgsExpressionContextScope *QgsExpressionContextUtils::compositionScope( const Qg
}

//add known composition context variables
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "layout_name" ), composition->name(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "layout_numpages" ), composition->numPages(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "layout_pageheight" ), composition->paperHeight(), true ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "layout_pagewidth" ), composition->paperWidth(), true ) );

0 comments on commit 29a8c0c

Please sign in to comment.