Finish 1.4.6

This commit is contained in:
Arin Alexander 2017-03-07 19:09:34 +03:00
commit 8fd7c27837
5 changed files with 42 additions and 12 deletions

View File

@ -67,4 +67,13 @@ QString replaceHTMLSymbols(const QString &value)
return result; return result;
} }
QVector<QString> normalizeCaptures(const QRegExp& reg){
QVector<QString> result;
foreach (QString cap, reg.capturedTexts()) {
if (!cap.isEmpty())
result.append(cap);
}
return result;
}
} //namespace LimeReport } //namespace LimeReport

View File

@ -90,7 +90,8 @@ namespace Const{
//const int VALUE_INDEX = 2; //const int VALUE_INDEX = 2;
//const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(?:(?:((?:(?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"?\\$S\\s*\\{\\s*)|(?:\\\"))((?:\\w+\\.?\\w+)|(?:\\w+))(?:(?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,)|(?:))\\s*\\\"(\\w+)\\\"\\s*\\)"; //const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(?:(?:((?:(?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"?\\$S\\s*\\{\\s*)|(?:\\\"))((?:\\w+\\.?\\w+)|(?:\\w+))(?:(?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,)|(?:))\\s*\\\"(\\w+)\\\"\\s*\\)";
const QString GROUP_FUNCTION_PARAM_RX = "\\((?:(.+),|(?:))(?:\\\"(\\w+)\\\")\\)"; //const QString GROUP_FUNCTION_PARAM_RX = "\\((?:(.+),(.+))|(?:\\\"(\\w+)\\\")\\)";
const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(?:(?:(?:(?:\\\")|(?:))(\\w+)(?:(?:\\\")|(?:)))|(?:(?:(?:\\\")|(?:))(\\s*\\$\\w\\s*\\{.+\\}\\s*)(?:(?:\\\")|(?:))\\s*,\\s*(?:(?:\\\")|(?:))(\\w+)(?:(?:\\\")|(?:))))\\)";
const int DATASOURCE_INDEX = 3;//4; const int DATASOURCE_INDEX = 3;//4;
const int VALUE_INDEX = 2; //2; const int VALUE_INDEX = 2; //2;
const int EXPRESSION_ARGUMENT_INDEX = 1;//3; const int EXPRESSION_ARGUMENT_INDEX = 1;//3;
@ -103,6 +104,7 @@ namespace Const{
QString extractClassName(QString className); QString extractClassName(QString className);
QString escapeSimbols(const QString& value); QString escapeSimbols(const QString& value);
QString replaceHTMLSymbols(const QString &value); QString replaceHTMLSymbols(const QString &value);
QVector<QString> normalizeCaptures(const QRegExp &reg);
enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols}; enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols};
enum RenderPass {FirstPass, SecondPass}; enum RenderPass {FirstPass, SecondPass};

View File

@ -67,4 +67,13 @@ QString replaceHTMLSymbols(const QString &value)
return result; return result;
} }
QVector<QString> normalizeCaptures(const QRegExp& reg){
QVector<QString> result;
foreach (QString cap, reg.capturedTexts()) {
if (!cap.isEmpty())
result.append(cap);
}
return result;
}
} //namespace LimeReport } //namespace LimeReport

View File

@ -90,7 +90,8 @@ namespace Const{
//const int VALUE_INDEX = 2; //const int VALUE_INDEX = 2;
//const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(?:(?:((?:(?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"?\\$S\\s*\\{\\s*)|(?:\\\"))((?:\\w+\\.?\\w+)|(?:\\w+))(?:(?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,)|(?:))\\s*\\\"(\\w+)\\\"\\s*\\)"; //const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(?:(?:((?:(?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"?\\$S\\s*\\{\\s*)|(?:\\\"))((?:\\w+\\.?\\w+)|(?:\\w+))(?:(?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,)|(?:))\\s*\\\"(\\w+)\\\"\\s*\\)";
const QString GROUP_FUNCTION_PARAM_RX = "\\((?:(.+),|(?:))(?:\\\"(\\w+)\\\")\\)"; //const QString GROUP_FUNCTION_PARAM_RX = "\\((?:(.+),(.+))|(?:\\\"(\\w+)\\\")\\)";
const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(?:(?:(?:(?:\\\")|(?:))(\\w+)(?:(?:\\\")|(?:)))|(?:(?:(?:\\\")|(?:))(\\s*\\$\\w\\s*\\{.+\\}\\s*)(?:(?:\\\")|(?:))\\s*,\\s*(?:(?:\\\")|(?:))(\\w+)(?:(?:\\\")|(?:))))\\)";
const int DATASOURCE_INDEX = 3;//4; const int DATASOURCE_INDEX = 3;//4;
const int VALUE_INDEX = 2; //2; const int VALUE_INDEX = 2; //2;
const int EXPRESSION_ARGUMENT_INDEX = 1;//3; const int EXPRESSION_ARGUMENT_INDEX = 1;//3;
@ -103,6 +104,7 @@ namespace Const{
QString extractClassName(QString className); QString extractClassName(QString className);
QString escapeSimbols(const QString& value); QString escapeSimbols(const QString& value);
QString replaceHTMLSymbols(const QString &value); QString replaceHTMLSymbols(const QString &value);
QVector<QString> normalizeCaptures(const QRegExp &reg);
enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols}; enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols};
enum RenderPass {FirstPass, SecondPass}; enum RenderPass {FirstPass, SecondPass};

View File

@ -367,15 +367,19 @@ void ReportRender::extractGroupsFunction(BandDesignIntf *band)
if (rx.indexIn(contentItem->content())>=0){ if (rx.indexIn(contentItem->content())>=0){
int pos = 0; int pos = 0;
while ( (pos = rx.indexIn(contentItem->content(),pos)) != -1){ while ( (pos = rx.indexIn(contentItem->content(),pos)) != -1){
BandDesignIntf* dataBand = m_patternPageItem->bandByName(rx.cap(Const::DATASOURCE_INDEX)); QVector<QString> captures = normalizeCaptures(rx);
if (dataBand){ if (captures.size()>=3){
GroupFunction* gf = datasources()->addGroupFunction(functionName,rx.cap(Const::VALUE_INDEX),band->objectName(),dataBand->objectName()); int dsIndex = captures.size() == 3 ? Const::DATASOURCE_INDEX - 1 : Const::DATASOURCE_INDEX;
if (gf){ BandDesignIntf* dataBand = m_patternPageItem->bandByName(captures.at(dsIndex));
connect(dataBand,SIGNAL(bandRendered(BandDesignIntf*)),gf,SLOT(slotBandRendered(BandDesignIntf*))); if (dataBand){
GroupFunction* gf = datasources()->addGroupFunction(functionName,captures.at(Const::VALUE_INDEX),band->objectName(),dataBand->objectName());
if (gf){
connect(dataBand,SIGNAL(bandRendered(BandDesignIntf*)),gf,SLOT(slotBandRendered(BandDesignIntf*)));
}
} else {
GroupFunction* gf = datasources()->addGroupFunction(functionName,captures.at(Const::VALUE_INDEX),band->objectName(),captures.at(dsIndex));
gf->setInvalid(tr("Databand \"%1\" not found").arg(captures.at(dsIndex)));
} }
} else {
GroupFunction* gf = datasources()->addGroupFunction(functionName,rx.cap(Const::VALUE_INDEX),band->objectName(),rx.cap(Const::DATASOURCE_INDEX));
gf->setInvalid(tr("Databand \"%1\" not found").arg(rx.cap(Const::DATASOURCE_INDEX)));
} }
pos += rx.matchedLength(); pos += rx.matchedLength();
} }
@ -388,6 +392,7 @@ void ReportRender::extractGroupsFunction(BandDesignIntf *band)
} }
} }
void ReportRender::replaceGroupsFunction(BandDesignIntf *band) void ReportRender::replaceGroupsFunction(BandDesignIntf *band)
{ {
foreach(BaseDesignIntf* item,band->childBaseItems()){ foreach(BaseDesignIntf* item,band->childBaseItems()){
@ -399,8 +404,11 @@ void ReportRender::replaceGroupsFunction(BandDesignIntf *band)
if (rx.indexIn(content)>=0){ if (rx.indexIn(content)>=0){
int pos = 0; int pos = 0;
while ( (pos = rx.indexIn(content,pos))!= -1 ){ while ( (pos = rx.indexIn(content,pos))!= -1 ){
QString expressionIndex = datasources()->putGroupFunctionsExpressions(rx.cap(Const::VALUE_INDEX)); QVector<QString> captures = normalizeCaptures(rx);
content.replace(rx.capturedTexts().at(0),QString("%1(%2,%3)").arg(functionName).arg('"'+expressionIndex+'"').arg('"'+band->objectName()+'"')); if (captures.size() >= 3){
QString expressionIndex = datasources()->putGroupFunctionsExpressions(captures.at(Const::VALUE_INDEX));
content.replace(captures.at(0),QString("%1(%2,%3)").arg(functionName).arg('"'+expressionIndex+'"').arg('"'+band->objectName()+'"'));
}
pos += rx.matchedLength(); pos += rx.matchedLength();
} }
contentItem->setContent(content); contentItem->setContent(content);