Tag: cws_src680_reportdesign01
User: oj      
Date: 2007-10-09 08:27:21+0000
Modified:
   dba/reportdesign/source/ui/dlg/Navigator.cxx
   dba/reportdesign/source/ui/inc/GeometryHandler.hxx
   dba/reportdesign/source/ui/inspection/GeometryHandler.cxx
   dba/reportdesign/source/ui/inspection/inspection.src

Log:
 #i77604# impl add function

File Changes:

Directory: /dba/reportdesign/source/ui/dlg/
===========================================

File [changed]: Navigator.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/dlg/Navigator.cxx?r1=1.3.20.1&r2=1.3.20.2
Delta lines:  +12 -10
---------------------
--- Navigator.cxx       2007-10-05 11:51:07+0000        1.3.20.1
+++ Navigator.cxx       2007-10-09 08:27:17+0000        1.3.20.2
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: Navigator.cxx,v $
  *
- *  $Revision: 1.3.20.1 $
+ *  $Revision: 1.3.20.2 $
  *
- *  last change: $Author: oj $ $Date: 2007/10/05 11:51:07 $
+ *  last change: $Author: oj $ $Date: 2007/10/09 08:27:17 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -140,10 +140,12 @@
     return nId;
 }
 // 
-----------------------------------------------------------------------------
-::rtl::OUString lcl_getName(const uno::Reference< report::XReportComponent>& 
_xElement)
+::rtl::OUString lcl_getName(const uno::Reference< beans::XPropertySet>& 
_xElement)
 {
     OSL_ENSURE(_xElement.is(),"Found report element which is NULL!");
-    ::rtl::OUStringBuffer sName = _xElement->getName();
+    ::rtl::OUString sTempName;
+    _xElement->getPropertyValue(PROPERTY_NAME) >>= sTempName;
+    ::rtl::OUStringBuffer sName = sTempName;
     uno::Reference< report::XFixedText> xFixedText(_xElement,uno::UNO_QUERY);
     uno::Reference< report::XReportControlModel> 
xReportModel(_xElement,uno::UNO_QUERY);
     if ( xFixedText.is() )
@@ -151,7 +153,7 @@
         sName.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" : ")));
         sName.append(xFixedText->getLabel());
     }
-    else if ( 
xReportModel->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD) )
+    else if ( xReportModel.is() && 
_xElement->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD) )
     {
         ReportFormula aFormula( xReportModel->getDataField() );
         if ( aFormula.isValid() )
@@ -594,7 +596,7 @@
     {
         uno::Reference< report::XReportComponent> 
xElement(_xSection->getByIndex(i),uno::UNO_QUERY);
         OSL_ENSURE(xElement.is(),"Found report element which is NULL!");
-        
insertEntry(lcl_getName(xElement),pSection,lcl_getImageId(xElement),LIST_APPEND,new
 UserData(this,xElement));
+        
insertEntry(lcl_getName(xElement.get()),pSection,lcl_getImageId(xElement),LIST_APPEND,new
 UserData(this,xElement));
         uno::Reference< report::XReportDefinition> 
xSubReport(xElement,uno::UNO_QUERY);
         if ( xSubReport.is() )
         {
@@ -767,8 +769,8 @@
     else
     {
         uno::Reference< report::XReportComponent> 
xElement(xProp,uno::UNO_QUERY);
-        if ( xElement.is() )
-            sName = lcl_getName(xElement);
+        if ( xProp.is() )
+            sName = lcl_getName(xProp);
         insertEntry(sName,pEntry,(!xElement.is() ? 
USHORT(SID_RPT_NEW_FUNCTION) : lcl_getImageId(xElement)),LIST_APPEND,new 
UserData(this,xProp));
     }
     if ( !IsExpanded(pEntry) )
@@ -909,8 +911,8 @@
         }
         else if ( PROPERTY_DATAFIELD == _rEvent.PropertyName || PROPERTY_LABEL 
== _rEvent.PropertyName || PROPERTY_NAME == _rEvent.PropertyName )
         {
-            uno::Reference< report::XReportComponent> 
xElement(_rEvent.Source,uno::UNO_QUERY);
-            m_pTree->SetEntryText(pEntry,lcl_getName(xElement));
+            uno::Reference<beans::XPropertySet> 
xProp(_rEvent.Source,uno::UNO_QUERY);
+            m_pTree->SetEntryText(pEntry,lcl_getName(xProp));
         }
     }
     catch(uno::Exception)

Directory: /dba/reportdesign/source/ui/inc/
===========================================

File [changed]: GeometryHandler.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/inc/GeometryHandler.hxx?r1=1.3.20.1&r2=1.3.20.2
Delta lines:  +19 -2
--------------------
--- GeometryHandler.hxx 2007-10-05 11:51:07+0000        1.3.20.1
+++ GeometryHandler.hxx 2007-10-09 08:27:18+0000        1.3.20.2
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: GeometryHandler.hxx,v $
  *
- *  $Revision: 1.3.20.1 $
+ *  $Revision: 1.3.20.2 $
  *
- *  last change: $Author: oj $ $Date: 2007/10/05 11:51:07 $
+ *  last change: $Author: oj $ $Date: 2007/10/09 08:27:18 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -133,6 +133,22 @@
 
         void impl_initFieldList_nothrow( ::com::sun::star::uno::Sequence< 
::rtl::OUString >& _rFieldNames ) const;
 
+        /** Creates the function defined by the function template
+        *
+        * \param _sFunctionName the function name
+        * \param _sDataField the data field
+        * \param _aFunction the function template
+        */
+        void impl_createFunction(const ::rtl::OUString& _sFunctionName,const 
::rtl::OUString& _sDataField,const DefaultFunction& _aFunction);
+
+        /** check whether the given function name is a countr function.
+        *
+        * \param _sFunctionName the function name to check
+        * \param _Out_sScope the scope of the function
+        * \return When true it is a counter functions otherwise false.
+        */
+        bool impl_isCounterFunction_throw(const ::rtl::OUString& 
_sFunctionName,::rtl::OUString& _Out_sScope) const;
+
         /** clear the own properties like function and scope and send a 
notification
         *
         * \param _aGuard 
@@ -247,6 +263,7 @@
         ::com::sun::star::uno::Sequence< ::rtl::OUString >                     
             m_aParamNames;
         TFunctions                                                             
             m_aFunctionNames;
         ::std::vector< DefaultFunction >                                       
             m_aDefaultFunctions;
+        DefaultFunction                                                        
             m_aCounterFunction;
         ::com::sun::star::uno::Reference< 
::com::sun::star::uno::XComponentContext >        m_xContext;
         mutable ::com::sun::star::uno::Reference< 
::com::sun::star::report::XFunction>      m_xFunction;
         ::com::sun::star::uno::Reference< 
::com::sun::star::inspection::XPropertyHandler >  m_xFormComponentHandler; /// 
delegatee

Directory: /dba/reportdesign/source/ui/inspection/
==================================================

File [changed]: GeometryHandler.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/inspection/GeometryHandler.cxx?r1=1.4.20.2&r2=1.4.20.3
Delta lines:  +151 -49
----------------------
--- GeometryHandler.cxx 2007-10-05 11:51:08+0000        1.4.20.2
+++ GeometryHandler.cxx 2007-10-09 08:27:18+0000        1.4.20.3
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: GeometryHandler.cxx,v $
  *
- *  $Revision: 1.4.20.2 $
+ *  $Revision: 1.4.20.3 $
  *
- *  last change: $Author: oj $ $Date: 2007/10/05 11:51:08 $
+ *  last change: $Author: oj $ $Date: 2007/10/09 08:27:18 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -217,7 +217,9 @@
 
 #define DATA_OR_FORMULA     0
 #define FUNCTION            1
-#define USER_DEF_FUNCTION   2
+#define COUNTER             2
+#define USER_DEF_FUNCTION   3
+
 //........................................................................
 namespace rptui
 {
@@ -481,6 +483,7 @@
                         if ( isDefaultFunction(sDataField,sDataField) )
                             aPropertyValue <<= sDataField;
                         break;
+                    case COUNTER:
                     case USER_DEF_FUNCTION:
                         aPropertyValue = uno::Any();
                         break;
@@ -501,7 +504,12 @@
                     else if ( isDefaultFunction(sDataField,sDataField) )
                         m_nDataFieldType = FUNCTION;
                     else if ( m_aFunctionNames.find(sDataField) != 
m_aFunctionNames.end() )
+                    {
                         m_nDataFieldType = USER_DEF_FUNCTION;
+                        ::rtl::OUString sScope;
+                        if ( impl_isCounterFunction_throw(sDataField,sScope) )
+                            m_nDataFieldType = COUNTER;
+                    }
                     else
                         m_nDataFieldType = DATA_OR_FORMULA;
                 }
@@ -526,6 +534,10 @@
                     case USER_DEF_FUNCTION:
                         aPropertyValue = (PROPERTY_ID_FORMULALIST == nId ? 
aDataField : uno::makeAny(::rtl::OUString()));
                         break;
+                    case COUNTER:
+                        if ( PROPERTY_ID_SCOPE == nId && 
impl_isCounterFunction_throw(sDataField,m_sScope) )
+                            aPropertyValue <<= m_sScope;
+                        break;
                 }
                 
             }            
@@ -563,12 +575,14 @@
                 bHandled = true;
                 const ::rtl::OUString sOldFunctionName = m_sDefaultFunction;
                 const ::rtl::OUString sOldScope = m_sScope;
-                m_sScope = m_sDefaultFunction = ::rtl::OUString();
-                m_xFunction.clear();
+
                 uno::Any aPropertyValue;
                 lcl_convertFormulaTo(Value,aPropertyValue);
                 ::rtl::OUString sDataField;
                 aPropertyValue >>= sDataField;
+
+                m_sScope = m_sDefaultFunction = ::rtl::OUString();
+                m_xFunction.clear();
                 const sal_uInt32 nOldDataFieldType = m_nDataFieldType;
                 if ( sDataField.getLength() )
                 {
@@ -585,11 +599,36 @@
             {
                 bHandled = true;
                 Value >>= m_nDataFieldType;
+
                 const ::rtl::OUString sOldFunctionName = m_sDefaultFunction;
                 const ::rtl::OUString sOldScope = m_sScope;
                 m_sDefaultFunction = m_sScope = m_sDefaultFunction = 
::rtl::OUString();
+
+                if ( m_nDataFieldType == COUNTER )
+                {
+                    uno::Any aDataField = 
m_xReportComponent->getPropertyValue( PROPERTY_DATAFIELD );
+                    lcl_convertFormulaTo(aDataField,aDataField);
+                    ::rtl::OUString sDataField;
+                    aDataField >>= sDataField;
+                    ::rtl::OUString sScope;
+                    if ( !(sDataField.getLength() && 
m_aFunctionNames.find(sDataField) != m_aFunctionNames.end() && 
impl_isCounterFunction_throw(sDataField,sScope)) )
+                    {
+                        sDataField = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Counter"));
+                        if ( !m_sScope.getLength() )
+                            fillScope_throw();
+                        sDataField += m_sScope;
+                        
impl_createFunction(sDataField,::rtl::OUString(),m_aCounterFunction);
+                        sDataField = lcl_getQuotedFunctionName(sDataField);
+                    }
+                    
m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny(impl_convertToFormula(
 uno::makeAny(sDataField))));
+                }
+                else
+                {
+                    if ( m_bNewFunction )
+                        removeFunction();
                 m_xFunction.clear();
-                
m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny(m_sDefaultFunction));
+                    
m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny(::rtl::OUString()));
+                }
                 
resetOwnProperties(aGuard,sOldFunctionName,sOldScope,m_nDataFieldType);
             }
             break;
@@ -643,13 +682,13 @@
                     lcl_convertFormulaTo(aPropertyValue,aPropertyValue);
                     ::rtl::OUString sDataField;
                     aPropertyValue >>= sDataField;
-                    if ( !isDefaultFunction(sDataField,sDataField) || 
sFunction != m_sDefaultFunction )
+                    if ( m_nDataFieldType == FUNCTION && 
(!isDefaultFunction(sDataField,sDataField) || m_sDefaultFunction != sFunction) )
                     {
                         if ( m_bNewFunction )
                             removeFunction();
-                        m_xFunction.clear();
                         // function currently does not exist
                         createDefaultFunction(aGuard,sFunction,sDataField);
+                        m_sDefaultFunction = sFunction;
                     }
                 }
             }
@@ -1404,7 +1443,7 @@
     return 
m_xFormComponentHandler->onInteractivePropertySelection(PropertyName, Primary, 
_rData, _rxInspectorUI);
 }
 
-void SAL_CALL GeometryHandler::actuatingPropertyChanged(const ::rtl::OUString 
& ActuatingPropertyName, const uno::Any & NewValue, const uno::Any & OldValue, 
const uno::Reference< inspection::XObjectInspectorUI > & _rxInspectorUI, 
::sal_Bool FirstTimeInit) throw (uno::RuntimeException, 
lang::NullPointerException)
+void SAL_CALL GeometryHandler::actuatingPropertyChanged(const ::rtl::OUString 
& ActuatingPropertyName, const uno::Any & NewValue, const uno::Any & OldValue, 
const uno::Reference< inspection::XObjectInspectorUI > & _rxInspectorUI, 
::sal_Bool _bFirstTimeInit) throw (uno::RuntimeException, 
lang::NullPointerException)
 {
     if ( !_rxInspectorUI.is() )
         throw lang::NullPointerException();
@@ -1420,18 +1459,19 @@
                 switch(nNewVal)
                 {
                     case DATA_OR_FORMULA:
+                        _rxInspectorUI->rebuildPropertyUI(PROPERTY_DATAFIELD);
                         
_rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_True);
                         
_rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,sal_False);
                         
_rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,sal_False);
                         OSL_ENSURE(m_sDefaultFunction.getLength() == 0,"Why is 
the m_sDefaultFunction set?");
                         OSL_ENSURE(m_sScope.getLength() == 0,"Why is the 
m_sScope set?");
-                        _rxInspectorUI->rebuildPropertyUI(PROPERTY_DATAFIELD);
                         break;
                     case FUNCTION:
+                        _rxInspectorUI->rebuildPropertyUI(PROPERTY_DATAFIELD);
+                        
_rxInspectorUI->rebuildPropertyUI(PROPERTY_FORMULALIST);
                         
_rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_True);
                         
_rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,m_sDefaultFunction.getLength()
 != 0);
                         
_rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,m_sScope.getLength() != 0);
-                        _rxInspectorUI->rebuildPropertyUI(PROPERTY_DATAFIELD);
                         break;
                     case USER_DEF_FUNCTION:
                         
_rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_False);
@@ -1439,12 +1479,23 @@
                         
_rxInspectorUI->rebuildPropertyUI(PROPERTY_FORMULALIST);
                         
_rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,sal_False);
                         break;
+                    case COUNTER:
+                        
_rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_False);
+                        
_rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,sal_False);
+                        
_rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,sal_True);
+                        break;
                 }
             }
             break;
         case PROPERTY_ID_DATAFIELD:
             {
-                sal_Bool bEnable = m_nDataFieldType != DATA_OR_FORMULA;
+                sal_Bool bEnable = (m_nDataFieldType != DATA_OR_FORMULA && 
m_nDataFieldType != COUNTER );
+                if ( bEnable )
+                {
+                    ::rtl::OUString sValue;
+                    m_xReportComponent->getPropertyValue( PROPERTY_DATAFIELD ) 
>>= sValue;
+                    bEnable = sValue.getLength() != 0;
+                }
                 _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,bEnable);
                 if ( bEnable )
                 {
@@ -1455,7 +1506,7 @@
             break;
         case PROPERTY_ID_FORMULALIST:
             {
-                
_rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,m_nDataFieldType == FUNCTION);
+                
_rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,m_nDataFieldType == FUNCTION || 
m_nDataFieldType == COUNTER);
             }
             break;
         case PROPERTY_ID_BACKTRANSPARENT:
@@ -1469,7 +1520,7 @@
             }
             break;
         default:
-            
m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, 
NewValue, OldValue, _rxInspectorUI, FirstTimeInit);
+            
m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, 
NewValue, OldValue, _rxInspectorUI, _bFirstTimeInit);
             break;
     }    
 }
@@ -1730,7 +1781,7 @@
                         xub_StrLen end = sFormula.Len();
                         if ( aTextSearch.SearchFrwrd(sFormula,&start,&end) && 
start == 0 && end == sFormula.Len()) // default function found
                         {
-                            aSearchOptions.searchString = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\\[[:alpha:]+[:alnum:]*\\]"));
+                            aSearchOptions.searchString = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]"));
                             utl::TextSearch aDataSearch(aSearchOptions);
                             aDataSearch.SearchFrwrd(sFormula,&start,&end );
                             ++start;
@@ -1771,6 +1822,14 @@
 {
     if ( m_aDefaultFunctions.empty() )
     {
+        m_aCounterFunction.m_bPreEvaluated = sal_False;
+        m_aCounterFunction.m_bDeepTraversing = sal_False;
+        m_aCounterFunction.m_sName = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Counter"));
+        m_aCounterFunction.m_sFormula = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[%FunctionName] + 1"));
+        m_aCounterFunction.m_sSearchString = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:\\[[:alpha:]+([:space:]*[:alnum:]*)*\\][:space:]*\\+[:space:]*[:digit:]*"));
+        m_aCounterFunction.m_sInitialFormula.IsPresent = sal_True;
+        m_aCounterFunction.m_sInitialFormula.Value = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1"));
+
         DefaultFunction aDefault;
         aDefault.m_bDeepTraversing = sal_False;
 
@@ -1784,7 +1843,7 @@
         aDefault.m_bPreEvaluated = sal_True;
         aDefault.m_sName = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Accumulation"));
         aDefault.m_sFormula = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[%Column] + [%FunctionName]"));
-        aDefault.m_sSearchString = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:\\[[:alpha:]+[:alnum:]*\\][:space:]*\\+[:space:]*\\[[:alpha:]+[:alnum:]*\\]"));
+        aDefault.m_sSearchString = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:\\[[:alpha:]+([:space:]*[:alnum:]*)*\\][:space:]*\\+[:space:]*\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]"));
         aDefault.m_sInitialFormula.IsPresent = sal_True;
         aDefault.m_sInitialFormula.Value = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[%Column]"));
         m_aDefaultFunctions.push_back(aDefault);
@@ -1793,14 +1852,14 @@
 
         aDefault.m_sName = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Minimum"));
         aDefault.m_sFormula = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:IF([%Column] < 
[%FunctionName];[%Column];[%FunctionName])"));
-        aDefault.m_sSearchString = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:IF\\(\\[[:alpha:]+[:alnum:]*\\][:space:]*<[:space:]*\\[[:alpha:]+[:alnum:]*\\];[:space:]*\\[[:alpha:]+[:alnum:]*\\];[:space:]*\\[[:alpha:]+[:alnum:]*\\]\\)"));
+        aDefault.m_sSearchString = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:IF\\((\\[[:alpha:]+([:space:]*[:alnum:]*)*\\])[:space:]*<[:space:]*(\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]);[:space:]*\\1[:space:]*;[:space:]*\\3[:space:]*\\)"));
         aDefault.m_sInitialFormula.IsPresent = sal_True;
         aDefault.m_sInitialFormula.Value = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[%Column]"));
         m_aDefaultFunctions.push_back(aDefault);
 
         aDefault.m_sName = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Maximum"));
         aDefault.m_sFormula = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:IF([%Column] > 
[%FunctionName];[%Column];[%FunctionName])"));
-        aDefault.m_sSearchString = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:IF\\(\\[[:alpha:]+[:alnum:]*\\][:space:]*>[:space:]*\\[[:alpha:]+[:alnum:]*\\];[:space:]*\\[[:alpha:]+[:alnum:]*\\];[:space:]*\\[[:alpha:]+[:alnum:]*\\]\\)"));
+        aDefault.m_sSearchString = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:IF\\((\\[[:alpha:]+([:space:]*[:alnum:]*)*\\])[:space:]*>[:space:]*(\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]);[:space:]*\\1[:space:]*;[:space:]*\\3[:space:]*\\)"));
         aDefault.m_sInitialFormula.IsPresent = sal_True;
         aDefault.m_sInitialFormula.Value = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[%Column]"));
         m_aDefaultFunctions.push_back(aDefault);
@@ -1832,34 +1891,8 @@
                     isDefaultFunction(sQuotedFunctionName,sTemp,true); // 
implicitly sets the m_sScope
                 }
                 else
-                {
-                    m_xFunction.set(report::Function::create(m_xContext));
-                    m_xFunction->setName( sFunctionName );
+                    impl_createFunction(sFunctionName,_sDataField,*aIter);
 
-                    const String 
sPlaceHolder1(RTL_CONSTASCII_USTRINGPARAM("%Column"));
-                    const String 
sPlaceHolder2(RTL_CONSTASCII_USTRINGPARAM("%FunctionName"));
-                    String sFormula(aIter->m_sFormula);
-                    sFormula.SearchAndReplaceAll(sPlaceHolder1,_sDataField);
-                    sFormula.SearchAndReplaceAll(sPlaceHolder2,sFunctionName);
-
-                    m_xFunction->setFormula(sFormula);
-                    m_xFunction->setPreEvaluated(aIter->m_bPreEvaluated);
-                    m_xFunction->setDeepTraversing(aIter->m_bDeepTraversing);
-                    if ( aIter->m_sInitialFormula.IsPresent )
-                    {
-                        beans::Optional< ::rtl::OUString> aInitialFormula = 
aIter->m_sInitialFormula;
-                        String sInitialFormula = aInitialFormula.Value;
-                        
sInitialFormula.SearchAndReplaceAll(sPlaceHolder1,_sDataField);
-                        
sInitialFormula.SearchAndReplaceAll(sPlaceHolder2,sFunctionName);
-                        aInitialFormula.Value = sInitialFormula;
-                        m_xFunction->setInitialFormula( aInitialFormula );
-                    }
-                    const uno::Reference< report::XFunctionsSupplier> 
xFunctionsSupplier = fillScope_throw();
-                    const uno::Reference< container::XIndexContainer> 
xFunctions(xFunctionsSupplier->getFunctions(),uno::UNO_QUERY_THROW);
-                    
xFunctions->insertByIndex(xFunctions->getCount(),uno::makeAny(m_xFunction));
-                    
m_aFunctionNames.insert(TFunctions::value_type(sQuotedFunctionName,TFunctionPair(m_xFunction,xFunctionsSupplier)));
-                    m_bNewFunction = true;
-                }
                 
m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny( 
impl_convertToFormula( uno::makeAny(sQuotedFunctionName) )));
                 aEvent.NewValue <<= m_sScope;
                 _aGuard.clear();
@@ -1963,6 +1996,75 @@
         DBG_ERROR( "GeometryHandler::impl_initFieldList_nothrow: caught an 
exception!" )
     }
 }
+// 
-----------------------------------------------------------------------------
+bool GeometryHandler::impl_isCounterFunction_throw(const ::rtl::OUString& 
_sFunctionName,::rtl::OUString& _Out_sScope) const
+{
+    ::std::pair<TFunctions::const_iterator,TFunctions::const_iterator> aFind = 
m_aFunctionNames.equal_range(_sFunctionName);
+    while ( aFind.first != aFind.second )
+    {
+        const beans::Optional< ::rtl::OUString> aInitalFormula = 
aFind.first->second.first->getInitialFormula();
+        if ( aInitalFormula.IsPresent )
+        {
+            const String sFormula( aFind.first->second.first->getFormula() );
+            util::SearchOptions aSearchOptions;
+            aSearchOptions.algorithmType = util::SearchAlgorithms_REGEXP;
+            aSearchOptions.searchFlag = 0x00000100;
+            aSearchOptions.searchString = m_aCounterFunction.m_sSearchString;
+            utl::TextSearch aTextSearch(aSearchOptions);
+            xub_StrLen start = 0;
+            xub_StrLen end = sFormula.Len();
+            if ( aTextSearch.SearchFrwrd(sFormula,&start,&end) && start == 0 
&& end == sFormula.Len()) // counter function found
+            {
+                uno::Reference< report::XGroup > 
xGroup(aFind.first->second.second,uno::UNO_QUERY);
+                if ( xGroup.is() )
+                {
+                    String sGroupName = String(ModuleRes(RID_STR_SCOPE_GROUP));
+                    
sGroupName.SearchAndReplaceAscii("%1",xGroup->getExpression());
+                    _Out_sScope = sGroupName;
+                }
+                else
+                    _Out_sScope = uno::Reference< report::XReportDefinition 
>(aFind.first->second.second,uno::UNO_QUERY_THROW)->getName();
+                break;
+            }
+        }
+        ++(aFind.first);
+    }
+    return aFind.first != aFind.second;
+}
+// 
-----------------------------------------------------------------------------
+void GeometryHandler::impl_createFunction(const ::rtl::OUString& 
_sFunctionName,const ::rtl::OUString& _sDataField,const DefaultFunction& 
_aFunction)
+{
+    if ( m_bNewFunction )
+        removeFunction();
+
+    const ::rtl::OUString 
sQuotedFunctionName(lcl_getQuotedFunctionName(_sFunctionName));
+    m_xFunction.set(report::Function::create(m_xContext));
+    m_xFunction->setName( _sFunctionName );
+
+    const String sPlaceHolder1(RTL_CONSTASCII_USTRINGPARAM("%Column"));
+    const String sPlaceHolder2(RTL_CONSTASCII_USTRINGPARAM("%FunctionName"));
+    String sFormula(_aFunction.m_sFormula);
+    sFormula.SearchAndReplaceAll(sPlaceHolder1,_sDataField);
+    sFormula.SearchAndReplaceAll(sPlaceHolder2,_sFunctionName);
+
+    m_xFunction->setFormula(sFormula);
+    m_xFunction->setPreEvaluated(_aFunction.m_bPreEvaluated);
+    m_xFunction->setDeepTraversing(_aFunction.m_bDeepTraversing);
+    if ( _aFunction.m_sInitialFormula.IsPresent )
+    {
+        beans::Optional< ::rtl::OUString> aInitialFormula = 
_aFunction.m_sInitialFormula;
+        String sInitialFormula = aInitialFormula.Value;
+        sInitialFormula.SearchAndReplaceAll(sPlaceHolder1,_sDataField);
+        sInitialFormula.SearchAndReplaceAll(sPlaceHolder2,_sFunctionName);
+        aInitialFormula.Value = sInitialFormula;
+        m_xFunction->setInitialFormula( aInitialFormula );
+    }
+    const uno::Reference< report::XFunctionsSupplier> xFunctionsSupplier = 
fillScope_throw();
+    const uno::Reference< container::XIndexContainer> 
xFunctions(xFunctionsSupplier->getFunctions(),uno::UNO_QUERY_THROW);
+    
xFunctions->insertByIndex(xFunctions->getCount(),uno::makeAny(m_xFunction));
+    
m_aFunctionNames.insert(TFunctions::value_type(sQuotedFunctionName,TFunctionPair(m_xFunction,xFunctionsSupplier)));
+    m_bNewFunction = true;
+}
 //........................................................................
 } // namespace rptui
 //........................................................................

File [changed]: inspection.src
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/source/ui/inspection/inspection.src?r1=1.3.26.2&r2=1.3.26.3
Delta lines:  +3 -3
-------------------
--- inspection.src      2007-10-05 11:51:08+0000        1.3.26.2
+++ inspection.src      2007-10-09 08:27:18+0000        1.3.26.3
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: inspection.src,v $
  *
- *  $Revision: 1.3.26.2 $
+ *  $Revision: 1.3.26.3 $
  *
- *  last change: $Author: oj $ $Date: 2007/10/05 11:51:08 $
+ *  last change: $Author: oj $ $Date: 2007/10/09 08:27:18 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -262,5 +262,5 @@
 };
 String RID_STR_TYPE_CONST
 {      
-    Text [ en-US ] = "Field or Formula;Function;User defined Function";
+    Text [ en-US ] = "Field or Formula;Function;Counter;User defined Function";
 };




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to