29#include <com/sun/star/report/GroupOn.hpp>
30#include <com/sun/star/report/KeepTogether.hpp>
32#include <osl/diagnose.h>
44 sal_Int16 nRet = report::KeepTogether::NO;
51 ,
const Reference< XFastAttributeList > & _xAttrList
56 m_xGroups = _rImport.getReportDefinition()->getGroups();
57 OSL_ENSURE(m_xGroups.is(),
"Groups is NULL!");
58 m_xGroup = m_xGroups->createGroup();
60 m_xGroup->setSortAscending(
false);
65 switch( aIter.getToken() )
78 OUString sValue = aIter.toString();
79 sal_Int32 nLen = sValue.getLength();
83 static const char s_sChanged[] =
"rpt:HASCHANGED(\"";
84 sal_Int32
nPos = sValue.indexOf(s_sChanged);
89 nPos = strlen(s_sChanged);
90 static const char s_sQuote[] =
"\"\"";
91 sal_Int32
nIndex = sValue.indexOf(s_sQuote,nPos);
94 sValue = sValue.replaceAt(nIndex,2, u
"\"");
95 nIndex = sValue.indexOf(s_sQuote,nIndex+2);
97 nLen = sValue.getLength() - 1;
99 sValue = sValue.copy(nPos,nLen-nPos-1);
101 ORptFilter::TGroupFunctionMap::const_iterator aFind = aFunctions.find(sValue);
102 if ( aFind != aFunctions.end() )
104 const OUString sCompleteFormula = aFind->second->getFormula();
105 OUString sExpression = sCompleteFormula.getToken(1,
'[');
106 sExpression = sExpression.getToken(0,
']');
109 ::sal_Int16 nGroupOn = report::GroupOn::DEFAULT;
111 if ( sFormula == u
"rpt:LEFT")
113 nGroupOn = report::GroupOn::PREFIX_CHARACTERS;
114 std::u16string_view sInterval =
o3tl::getToken(sCompleteFormula, 1,
';',nIndex);
118 else if ( sFormula == u
"rpt:YEAR")
119 nGroupOn = report::GroupOn::YEAR;
120 else if ( sFormula == u
"rpt:MONTH")
122 nGroupOn = report::GroupOn::MONTH;
124 else if ( sCompleteFormula.matchIgnoreAsciiCase(
"rpt:INT((MONTH",0)
125 && sCompleteFormula.endsWithIgnoreAsciiCase(
"-1)/3)+1") )
127 nGroupOn = report::GroupOn::QUARTAL;
129 else if ( sFormula == u
"rpt:WEEK")
130 nGroupOn = report::GroupOn::WEEK;
131 else if ( sFormula == u
"rpt:DAY")
132 nGroupOn = report::GroupOn::DAY;
133 else if ( sFormula == u
"rpt:HOUR")
134 nGroupOn = report::GroupOn::HOUR;
135 else if ( sFormula == u
"rpt:MINUTE")
136 nGroupOn = report::GroupOn::MINUTE;
137 else if ( sFormula == u
"rpt:INT")
139 nGroupOn = report::GroupOn::INTERVAL;
140 _rImport.removeFunction(sExpression);
141 sExpression = sExpression.copy(std::string_view(
"INT_count_").
size());
142 OUString sInterval = sCompleteFormula.getToken(1,
'/');
143 sInterval = sInterval.getToken(0,
')');
144 m_xGroup->setGroupInterval(sInterval.toInt32());
147 m_xGroup->setGroupOn(nGroupOn);
149 _rImport.removeFunction(sValue);
150 sValue = sExpression;
152 m_xGroup->setExpression(sValue);
164 catch(
const Exception&)
172OXMLGroup::~OXMLGroup()
177css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLGroup::createFastChildContext(
179 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
181 css::uno::Reference< css::xml::sax::XFastContextHandler > xContext;
189 xContext =
new OXMLFunction( rImport,xAttrList,m_xGroup);
195 m_xGroup->setHeaderOn(
true);
196 xContext =
new OXMLSection( rImport,xAttrList,m_xGroup->getHeader());
201 xContext =
new OXMLGroup( rImport,xAttrList);
207 xContext =
new OXMLSection( rImport,xAttrList, xComponent->getDetail());
214 m_xGroup->setFooterOn(
true);
215 xContext =
new OXMLSection( rImport,xAttrList,m_xGroup->getFooter());
230void OXMLGroup::endFastElement(sal_Int32 )
235 m_xGroups->insertByIndex(0,
uno::Any(m_xGroup));
236 }
catch(uno::Exception&)
static bool convertEnum(EnumT &rEnum, std::u16string_view rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
const Reference< XReportDefinition > & getReportDefinition() const
std::map< OUString, Reference< XFunction > > TGroupFunctionMap
OXMLGroup(const OXMLGroup &)
static const SvXMLEnumMapEntry< sal_Int16 > * GetKeepTogetherOptions()
#define TOOLS_WARN_EXCEPTION(area, stream)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
static sal_Int16 lcl_getKeepTogetherOption(std::string_view _sValue)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
#define PROGRESS_BAR_STEP
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)