Tag: cws_src680_reportdesign01
User: oj      
Date: 2007-10-11 07:45:20+0000
Modified:
   dba/reportdesign/source/ui/dlg/Navigator.cxx
   dba/reportdesign/source/ui/inc/GeometryHandler.hxx
   dba/reportdesign/source/ui/inspection/GeometryHandler.cxx

Log:
 #i77604# handle scope

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.2&r2=1.3.20.3
Delta lines:  +6 -3
-------------------
--- Navigator.cxx       2007-10-09 08:27:17+0000        1.3.20.2
+++ Navigator.cxx       2007-10-11 07:45:16+0000        1.3.20.3
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: Navigator.cxx,v $
  *
- *  $Revision: 1.3.20.2 $
+ *  $Revision: 1.3.20.3 $
  *
- *  last change: $Author: oj $ $Date: 2007/10/09 08:27:17 $
+ *  last change: $Author: oj $ $Date: 2007/10/11 07:45:16 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -228,7 +228,6 @@
        virtual sal_Int8        ExecuteDrop( const ExecuteDropEvent& _rEvt );
 
     // OSelectionChangeListener
-    virtual void _selectionChanged( const lang::EventObject& aEvent ) throw 
(uno::RuntimeException);
        virtual void _disposing(const lang::EventObject& _rSource) throw( 
uno::RuntimeException);
 
     // OPropertyChangeListener
@@ -246,6 +245,8 @@
     DECL_LINK(OnEntrySelDesel, NavigatorTree*);
     DECL_LINK( OnDropActionTimer, void* );
 
+    virtual void _selectionChanged( const lang::EventObject& aEvent ) throw 
(uno::RuntimeException);
+
     // ITraverseReport
     virtual void traverseReport(const uno::Reference< 
report::XReportDefinition>& _xReport);
     virtual void traverseReportFunctions(const uno::Reference< 
report::XFunctions>& _xFunctions);
@@ -962,6 +963,8 @@
     reportdesign::OReportVisitor aVisitor(m_pNavigatorTree.get());
     aVisitor.start(m_xReport);
     m_pNavigatorTree->Expand(m_pNavigatorTree->find(m_xReport));
+    lang::EventObject aEvent(*m_pController);
+    m_pNavigatorTree->_selectionChanged(aEvent);
 }
 //------------------------------------------------------------------------
 ONavigatorImpl::~ONavigatorImpl()

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.3&r2=1.3.20.4
Delta lines:  +32 -9
--------------------
--- GeometryHandler.hxx 2007-10-09 12:53:59+0000        1.3.20.3
+++ GeometryHandler.hxx 2007-10-11 07:45:17+0000        1.3.20.4
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: GeometryHandler.hxx,v $
  *
- *  $Revision: 1.3.20.3 $
+ *  $Revision: 1.3.20.4 $
  *
- *  last change: $Author: oj $ $Date: 2007/10/09 12:53:59 $
+ *  last change: $Author: oj $ $Date: 2007/10/11 07:45:17 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -102,6 +102,11 @@
         private ::cppu::BaseMutex,
         public GeometryHandler_Base
     {
+        /** sets the counter function at the data field.
+        *   If the counter function doesn't exist it will be created.
+        */
+        void impl_setCounterFunction_throw();
+
         /** executes a dialog for chosing a filter criterion for a database 
report
             @param _out_rSelectedClause
                 the filter or order clause as chosen by the user
@@ -114,9 +119,10 @@
 
         /** returns the data field type depending on the data field of the 
report control
         *
+        * \param _sDataField if the data field is not empty it will be used as 
data field, otherwise the data field will be used.
         * \return the data field type
         */
-        sal_uInt32 impl_getDataFieldType_throw() const;
+        sal_uInt32 impl_getDataFieldType_throw(const ::rtl::OUString& 
_sDataField = ::rtl::OUString()) const;
 
         ::com::sun::star::uno::Any getConstantValue(sal_Bool 
bToControlValue,sal_uInt16 nResId,const ::com::sun::star::uno::Any& 
_aValue,const ::rtl::OUString& _sConstantName,const ::rtl::OUString & 
PropertyName );
         ::com::sun::star::beans::Property getProperty(const ::rtl::OUString & 
PropertyName);
@@ -151,11 +157,11 @@
 
         /** check whether the given function name is a countr function.
         *
-        * \param _sFunctionName the function name to check
+        * \param _sQuotedFunctionName the quoted 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;
+        bool impl_isCounterFunction_throw(const ::rtl::OUString& 
_sQuotedFunctionName,::rtl::OUString& _Out_sScope) const;
 
         /** clear the own properties like function and scope and send a 
notification
         *
@@ -187,19 +193,35 @@
 
         /** get the functions supplier for the set scope, default is the 
surrounding group.
         *
+        * \param _rsNamePostFix the name post fix which canbe used when the 
scope as name part is needed
         * \return the function supplier
         */
-        ::com::sun::star::uno::Reference< 
::com::sun::star::report::XFunctionsSupplier> fillScope_throw();
+        ::com::sun::star::uno::Reference< 
::com::sun::star::report::XFunctionsSupplier> fillScope_throw(::rtl::OUString& 
_rsNamePostFix);
         ::rtl::OUString getFormula() const;
 
         /** checks if the given function is a default function we know.
         *
-        * \param _sFunction the function name
-        * \param _rDataField the data field which is used in the function
+        * \param _sQuotedFunction the quoted function name
+        * \param _Out_rDataField the data field which is used in the function
+        * \param _xFunctionsSupplier teh function supplier to search or empty 
if not used
         * \param _bSet If set to TRUE than the m_sDefaultFunction and m_sScope 
vars will be set if successful.
         * \return sal_True with known otherwise sal_False
         */
-        sal_Bool isDefaultFunction(const ::rtl::OUString& 
_sFunction,::rtl::OUString& _rDataField,bool _bSet = false) const;
+        sal_Bool isDefaultFunction(const ::rtl::OUString& _sQuotedFunction
+                                    ,::rtl::OUString& _Out_rDataField
+                                    ,const ::com::sun::star::uno::Reference< 
::com::sun::star::report::XFunctionsSupplier>& _xFunctionsSupplier = 
::com::sun::star::uno::Reference< 
::com::sun::star::report::XFunctionsSupplier>()
+                                    ,bool _bSet = false) const;
+
+        /** checks if the given function is a default function we know.
+        *
+        * \param _xFunction 
+        * \param _rDataField 
+        * \param _rsDefaultFunctionName 
+        * \return 
+        */
+        sal_Bool impl_isDefaultFunction_nothrow( const 
::com::sun::star::uno::Reference< ::com::sun::star::report::XFunction>& 
_xFunction
+                                            ,::rtl::OUString& _rDataField
+                                            ,::rtl::OUString& 
_rsDefaultFunctionName) const;
 
         /** fills the memeber m_aDefaultFunctions
         *
@@ -230,6 +252,7 @@
                virtual void SAL_CALL disposing(const 
::com::sun::star::lang::EventObject& Source) throw( 
::com::sun::star::uno::RuntimeException );
         // XPropertyChangeListener
                virtual void SAL_CALL propertyChange(const 
::com::sun::star::beans::PropertyChangeEvent& evt) 
throw(::com::sun::star::uno::RuntimeException);
+
     public:
         // XServiceInfo - static versions
                static ::rtl::OUString getImplementationName_Static(  ) 
throw(::com::sun::star::uno::RuntimeException);

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.6&r2=1.4.20.7
Delta lines:  +214 -149
-----------------------
--- GeometryHandler.cxx 2007-10-10 06:50:00+0000        1.4.20.6
+++ GeometryHandler.cxx 2007-10-11 07:45:17+0000        1.4.20.7
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: GeometryHandler.cxx,v $
  *
- *  $Revision: 1.4.20.6 $
+ *  $Revision: 1.4.20.7 $
  *
- *  last change: $Author: oj $ $Date: 2007/10/10 06:50:00 $
+ *  last change: $Author: oj $ $Date: 2007/10/11 07:45:17 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -239,22 +239,6 @@
                return x.equals(y.Name);// ? true : false;
        }
 };
-void lcl_collectFunctionNames(const uno::Reference< report::XFunctions>& 
_xFunctions,TFunctions& _rFunctionNames)
-{
-    const static ::rtl::OUString 
sLeftBracket(RTL_CONSTASCII_USTRINGPARAM("["));
-    const static ::rtl::OUString 
sRightBracket(RTL_CONSTASCII_USTRINGPARAM("]"));
-        
-    uno::Reference< report::XFunctionsSupplier> 
xParent(_xFunctions->getParent(),uno::UNO_QUERY);
-    const sal_Int32 nCount = _xFunctions->getCount();
-    for (sal_Int32 i = 0; i < nCount ; ++i)
-    {
-        uno::Reference< report::XFunction > 
xFunction(_xFunctions->getByIndex(i),uno::UNO_QUERY);
-        ::rtl::OUString sName = sLeftBracket;
-        sName += xFunction->getName();
-        sName += sRightBracket;
-        
_rFunctionNames.insert(TFunctions::value_type(sName,TFunctionPair(xFunction,xParent)));
-    }
-}
 // 
-----------------------------------------------------------------------------
 ::rtl::OUString lcl_getQuotedFunctionName(const ::rtl::OUString& _sFunction)
 {
@@ -268,10 +252,21 @@
     return lcl_getQuotedFunctionName(_xFunction->getName());
 }
 // 
-----------------------------------------------------------------------------
+void lcl_collectFunctionNames(const uno::Reference< report::XFunctions>& 
_xFunctions,TFunctions& _rFunctionNames)
+{
+    uno::Reference< report::XFunctionsSupplier> 
xParent(_xFunctions->getParent(),uno::UNO_QUERY_THROW);
+    const sal_Int32 nCount = _xFunctions->getCount();
+    for (sal_Int32 i = 0; i < nCount ; ++i)
+    {
+        uno::Reference< report::XFunction > 
xFunction(_xFunctions->getByIndex(i),uno::UNO_QUERY_THROW);
+        
_rFunctionNames.insert(TFunctions::value_type(lcl_getQuotedFunctionName(xFunction),TFunctionPair(xFunction,xParent)));
+    }
+}
+// 
-----------------------------------------------------------------------------
 void lcl_collectFunctionNames(const uno::Reference< report::XSection>& 
_xSection,TFunctions& _rFunctionNames)
 {
-    uno::Reference< report::XReportDefinition> xReportDefinition = 
_xSection->getReportDefinition();
-    uno::Reference< report::XGroups> xGroups = xReportDefinition->getGroups();
+    const uno::Reference< report::XReportDefinition> xReportDefinition = 
_xSection->getReportDefinition();
+    const uno::Reference< report::XGroups> xGroups = 
xReportDefinition->getGroups();
     sal_Int32 nPos = -1;
     uno::Reference< report::XGroup> xGroup = _xSection->getGroup();
     if ( xGroup.is() )
@@ -281,7 +276,7 @@
     
     for (sal_Int32 i = 0 ; i <= nPos ; ++i)
     {
-        xGroup.set(xGroups->getByIndex(i),uno::UNO_QUERY);
+        xGroup.set(xGroups->getByIndex(i),uno::UNO_QUERY_THROW);
         lcl_collectFunctionNames(xGroup->getFunctions(),_rFunctionNames);
     }
     
lcl_collectFunctionNames(xReportDefinition->getFunctions(),_rFunctionNames);
@@ -291,7 +286,7 @@
 {
     ::rtl::OUString sName;
     _aPropertyValue >>= sName;
-    sal_Int32 nLen = sName.getLength();
+    const sal_Int32 nLen = sName.getLength();
     if ( nLen )
     {
         ReportFormula aFormula( sName );
@@ -339,7 +334,7 @@
     DBG_CTOR(rpt_GeometryHandler,NULL);
     try
     {
-        uno::Reference< lang::XMultiComponentFactory > xFac = 
m_xContext->getServiceManager();
+        const uno::Reference< lang::XMultiComponentFactory > xFac = 
m_xContext->getServiceManager();
         
m_xFormComponentHandler.set(xFac->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.inspection.FormComponentPropertyHandler")),m_xContext),uno::UNO_QUERY_THROW);
         m_xTypeConverter.set(xFac->createInstanceWithContext( 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.script.Converter" 
)),m_xContext),uno::UNO_QUERY_THROW);
         loadDefaultFunctions();
@@ -402,6 +397,7 @@
         ::comphelper::disposeComponent(m_xTypeConverter);
         if ( m_xReportComponent.is() && 
m_xReportComponent->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD) 
)
             
m_xReportComponent->removePropertyChangeListener(PROPERTY_DATAFIELD,static_cast<
 beans::XPropertyChangeListener* >( this ));
+        
         m_xReportComponent.clear();
         m_xRowSet.clear();
         m_aPropertyListeners.clear();
@@ -434,13 +430,14 @@
     {
         if ( m_xReportComponent.is() && 
m_xReportComponent->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD) 
)
             
m_xReportComponent->removePropertyChangeListener(PROPERTY_DATAFIELD,static_cast<
 beans::XPropertyChangeListener* >( this ));
-        uno::Reference< container::XNameContainer > xObjectAsContainer( 
_rxInspectee, uno::UNO_QUERY );
+
+        const uno::Reference< container::XNameContainer > xObjectAsContainer( 
_rxInspectee, uno::UNO_QUERY );
         m_xReportComponent.set( xObjectAsContainer->getByName( 
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ReportComponent" ) ) ), 
uno::UNO_QUERY );
 
         const ::rtl::OUString sRowSet(RTL_CONSTASCII_USTRINGPARAM("RowSet"));
         if ( xObjectAsContainer->hasByName( sRowSet ) )
         {
-            uno::Any aRowSet = xObjectAsContainer->getByName(sRowSet);
+            const uno::Any aRowSet( xObjectAsContainer->getByName(sRowSet) );
             aRowSet >>= m_xRowSet;
             // forward the rowset to our delegator handler
             uno::Reference< beans::XPropertySet > xProp( 
m_xFormComponentHandler,uno::UNO_QUERY );
@@ -451,7 +448,8 @@
             if ( 
m_xReportComponent->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD) 
)
                 
m_xReportComponent->addPropertyChangeListener(PROPERTY_DATAFIELD,static_cast< 
beans::XPropertyChangeListener* >( this ));
         }
-        uno::Reference< report::XReportComponent> xReportComponent( 
m_xReportComponent, uno::UNO_QUERY );
+
+        const uno::Reference< report::XReportComponent> xReportComponent( 
m_xReportComponent, uno::UNO_QUERY);
         uno::Reference< report::XSection> xSection( m_xReportComponent, 
uno::UNO_QUERY );
         if ( !xSection.is() && xReportComponent.is() )
             xSection = xReportComponent->getSection();
@@ -500,7 +498,7 @@
             break;
         case PROPERTY_ID_TYPE:
             {
-                sal_uInt32 nOldDataFieldType = m_nDataFieldType;
+                const sal_uInt32 nOldDataFieldType = m_nDataFieldType;
                 m_nDataFieldType = impl_getDataFieldType_throw();
                 if ( UNDEF_DATA == m_nDataFieldType )
                     m_nDataFieldType = nOldDataFieldType;
@@ -519,8 +517,10 @@
                     case DATA_OR_FORMULA:
                         break;
                     case FUNCTION:
-                        if ( isDefaultFunction(sDataField,sDataField,true) )
+                        {
+                            if ( 
isDefaultFunction(sDataField,sDataField,uno::Reference< 
report::XFunctionsSupplier>(),true) )
                             aPropertyValue <<= (PROPERTY_ID_FORMULALIST == nId 
? m_sDefaultFunction : m_sScope);
+                        }
                         break;
                     case USER_DEF_FUNCTION:
                         aPropertyValue = (PROPERTY_ID_FORMULALIST == nId ? 
aDataField : uno::makeAny(::rtl::OUString()));
@@ -578,7 +578,7 @@
                 const sal_uInt32 nOldDataFieldType = m_nDataFieldType;
                 if ( sDataField.getLength() )
                 {
-                    if ( isDefaultFunction(sDataField,sDataField,true) )
+                    if ( 
isDefaultFunction(sDataField,sDataField,uno::Reference< 
report::XFunctionsSupplier>(),true) )
                         m_nDataFieldType = FUNCTION;
                     else if ( m_aFunctionNames.find(sDataField) != 
m_aFunctionNames.end() )
                         m_nDataFieldType = USER_DEF_FUNCTION;
@@ -598,22 +598,7 @@
 
                 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);
-                    }
-                    OBlocker aBlocker(m_bIn);
-                    
m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny(impl_convertToFormula(
 uno::makeAny(sDataField))));
+                    impl_setCounterFunction_throw();
                 }
                 else
                 {
@@ -657,15 +642,23 @@
                 {
                     ::rtl::OUString sDataField;
                     OBlocker aBlocker(m_bIn);
-                    if ( isDefaultFunction(sFunction,sDataField) )
+                    const sal_uInt32 nNewDataType = 
impl_getDataFieldType_throw(sFunction);
+                    if ( nNewDataType != UNDEF_DATA && nNewDataType != 
m_nDataFieldType )
                     {
                         const ::rtl::OUString sOldFunctionName = 
m_sDefaultFunction;
                         const ::rtl::OUString sOldScope = m_sScope;
                         m_sScope = m_sDefaultFunction = ::rtl::OUString();
                         m_xFunction.clear();
-                        isDefaultFunction(sFunction,sDataField,true);
+                        if ( nNewDataType == COUNTER )
+                            impl_isCounterFunction_throw(sFunction,m_sScope);
+                        else
+                        {
+                            ::rtl::OUString sNamePostFix;
+                            const uno::Reference< report::XFunctionsSupplier> 
xFunctionsSupplier = fillScope_throw(sNamePostFix);
+                            
isDefaultFunction(sFunction,sDataField,xFunctionsSupplier,true);
+                        }
                         const sal_uInt32 nOldDataFieldType = m_nDataFieldType;
-                        m_nDataFieldType = FUNCTION;
+                        m_nDataFieldType = nNewDataType;
                         
m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny(impl_convertToFormula(
 uno::makeAny(sFunction))));
                         
resetOwnProperties(aGuard,sOldFunctionName,sOldScope,nOldDataFieldType);
                     }
@@ -691,29 +684,34 @@
             
             break;
         case PROPERTY_ID_SCOPE:
-            if ( !(Value >>= m_sScope) ) /// TODO: the scope must be taken 
into account.
+            if ( !(Value >>= m_sScope) ) 
                 m_sScope = ::rtl::OUString();
             else
             {
-                OSL_ENSURE(m_xFunction.is(),"Where is my function gone!");
                 if ( m_bNewFunction )
-                {
                     removeFunction();
-                    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(lcl_getQuotedFunctionName(m_xFunction),TFunctionPair(m_xFunction,xFunctionsSupplier)));
-                    m_bNewFunction = true;
-                }
+                if ( m_nDataFieldType == COUNTER )
+                    impl_setCounterFunction_throw();
                 else
                 {
-                    uno::Any aPropertyValue = 
m_xReportComponent->getPropertyValue(PROPERTY_DATAFIELD);
-                    lcl_convertFormulaTo(aPropertyValue,aPropertyValue);
+                    OSL_ENSURE(m_xFunction.is(),"Where is my function gone!");
+
+                    ::rtl::OUString sNamePostFix;
+                    const uno::Reference< report::XFunctionsSupplier> 
xFunctionsSupplier = fillScope_throw(sNamePostFix);
+
+                    ::rtl::OUString 
sQuotedFunctionName(lcl_getQuotedFunctionName(m_xFunction));
+                    if ( 
isDefaultFunction(sQuotedFunctionName,sQuotedFunctionName,xFunctionsSupplier,true)
 )
+                        m_bNewFunction = false;
+                    else
+                    {
+                        ::rtl::OUString sDefaultFunctionName;
                     ::rtl::OUString sDataField;
-                    aPropertyValue >>= sDataField;
+                        OSL_VERIFY( 
impl_isDefaultFunction_nothrow(m_xFunction,sDataField,sDefaultFunctionName) );
+                        m_sDefaultFunction = sDefaultFunctionName;             
           
                     
createDefaultFunction(aGuard,m_sDefaultFunction,sDataField);
                 }
             }
+            }
             bHandled = true;
             break;
         case PROPERTY_ID_POSITIONX:
@@ -721,7 +719,7 @@
         case PROPERTY_ID_HEIGHT:
         case PROPERTY_ID_WIDTH:
             {
-                uno::Reference< report::XReportComponent> 
xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY);
+                const uno::Reference< report::XReportComponent> 
xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY);
                 if ( xSourceReportComponent.is() ) // check only report 
components
                 {
                     sal_Int32 nNewValue = 0;
@@ -743,7 +741,7 @@
             break;
         case PROPERTY_ID_CHARFONTNAME:
             {
-                uno::Reference< report::XReportControlFormat > 
xReportControlFormat( m_xReportComponent,uno::UNO_QUERY_THROW );
+                const uno::Reference< report::XReportControlFormat > 
xReportControlFormat( m_xReportComponent,uno::UNO_QUERY_THROW );
                 uno::Sequence< beans::NamedValue > aFontSettings;
                 OSL_VERIFY( Value >>= aFontSettings );
                 applyCharacterSettings( xReportControlFormat, aFontSettings );
@@ -785,7 +783,7 @@
         ,sal_Bool _bTrueIfListBoxFalseIfComboBox
     )
 {
-    uno::Reference< inspection::XStringListControl > xListControl(
+    const uno::Reference< inspection::XStringListControl > xListControl(
         _rxControlFactory->createPropertyControl(
             _bTrueIfListBoxFalseIfComboBox ? 
inspection::PropertyControlType::ListBox : 
inspection::PropertyControlType::ComboBox, _bReadOnlyControl
         ),
@@ -807,12 +805,12 @@
 
     try
     {
-        sal_Int32 count( _rxParams->getCount() );
-        _out_rParamNames.reserve( count );
+        const sal_Int32 nCount( _rxParams->getCount() );
+        _out_rParamNames.reserve( nCount );
 
         uno::Reference< beans::XPropertySet > xParam;
         ::rtl::OUString sParamName;
-        for ( sal_Int32 i=0; i<count; ++i )
+        for ( sal_Int32 i=0; i<nCount; ++i )
         {
             xParam.set( _rxParams->getByIndex(i), uno::UNO_QUERY_THROW );
             OSL_VERIFY( xParam->getPropertyValue( PROPERTY_NAME ) >>= 
sParamName );
@@ -976,7 +974,7 @@
         }
         else if ( PROPERTY_ID_HEIGHT == nId )
         {
-            uno::Reference< report::XSection> 
xSection(m_xReportComponent,uno::UNO_QUERY);
+            const uno::Reference< report::XSection> 
xSection(m_xReportComponent,uno::UNO_QUERY);
             if ( xSection.is() )
             {
                 sal_Int32 nHeight = 0;
@@ -1089,7 +1087,7 @@
                     ::rtl::OUString sControlValue;
                     _rControlValue >>= sControlValue;
                     
-                    uno::Reference< inspection::XStringRepresentation > 
xConversionHelper = inspection::StringRepresentation::create( 
m_xContext,m_xTypeConverter );
+                    const uno::Reference< inspection::XStringRepresentation > 
xConversionHelper = inspection::StringRepresentation::create( 
m_xContext,m_xTypeConverter );
                     aPropertyValue = 
xConversionHelper->convertToPropertyValue( sControlValue, aProp.Type );
                 }
                 else
@@ -1129,7 +1127,7 @@
                 aPropertyValue = 
m_xFormComponentHandler->convertToPropertyValue(PropertyName, _rControlValue);
                 sal_Int32 nPosX = 0;
                 aPropertyValue >>= nPosX;
-                uno::Reference< report::XReportComponent> 
xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY);
+                const uno::Reference< report::XReportComponent> 
xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY);
                 if ( xSourceReportComponent->getSection().is() )
                     nPosX += 
getStyleProperty<sal_Int32>(xSourceReportComponent->getSection()->getReportDefinition(),PROPERTY_LEFTMARGIN);
                 aPropertyValue <<= nPosX;
@@ -1210,7 +1208,7 @@
         {
             if ( _rControlValueType.getTypeClass() == uno::TypeClass_STRING )
             {
-                uno::Reference< inspection::XStringRepresentation > 
xConversionHelper = inspection::StringRepresentation::create( 
m_xContext,m_xTypeConverter );
+                const uno::Reference< inspection::XStringRepresentation > 
xConversionHelper = inspection::StringRepresentation::create( 
m_xContext,m_xTypeConverter );
                 aControlValue <<= xConversionHelper->convertToControlValue( 
aPropertyValue );
             }
             else
@@ -1248,7 +1246,7 @@
             {
                 sal_Int32 nPosX = 0;
                 aPropertyValue >>= nPosX;
-                uno::Reference< report::XReportComponent> 
xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY);
+                const uno::Reference< report::XReportComponent> 
xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY);
                 if ( xSourceReportComponent->getSection().is() )
                     nPosX -= 
getStyleProperty<sal_Int32>(xSourceReportComponent->getSection()->getReportDefinition(),PROPERTY_LEFTMARGIN);
                 aPropertyValue <<= nPosX;
@@ -1338,7 +1336,7 @@
         ,PROPERTY_CONTROLBACKGROUNDTRANSPARENT
         ,PROPERTY_LABEL
     };
-    uno::Reference < beans::XPropertySetInfo > xInfo = 
m_xReportComponent->getPropertySetInfo();
+    const uno::Reference < beans::XPropertySetInfo > xInfo = 
m_xReportComponent->getPropertySetInfo();
     const uno::Sequence< beans::Property> aSeq = xInfo->getProperties();
     for (size_t i = 0; i < 
sizeof(pIncludeProperties)/sizeof(pIncludeProperties[0]) ;++i )
     {
@@ -1368,7 +1366,7 @@
 uno::Sequence< ::rtl::OUString > SAL_CALL 
GeometryHandler::getSupersededProperties() throw (uno::RuntimeException)
 {
     uno::Sequence< ::rtl::OUString > aRet;
-    uno::Reference<report::XReportDefinition> 
xReport(m_xReportComponent,uno::UNO_QUERY);
+    const uno::Reference<report::XReportDefinition> 
xReport(m_xReportComponent,uno::UNO_QUERY);
     if ( xReport.is() && !uno::Reference< 
report::XSection>(xReport->getParent(),uno::UNO_QUERY).is() )
     {
         aRet.realloc(5);
@@ -1423,8 +1421,8 @@
         ::osl::ClearableMutexGuard aGuard( m_aMutex );
 
         inspection::InteractiveSelectionResult eResult = 
inspection::InteractiveSelectionResult_Cancelled;
-        uno::Reference< awt::XWindow> 
xInspectorWindow(m_xContext->getValueByName( 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogParentWindow"))) 
,uno::UNO_QUERY);
-        uno::Reference< report::XReportControlFormat> 
xReportControlFormat(m_xReportComponent,uno::UNO_QUERY);
+        const uno::Reference< awt::XWindow> 
xInspectorWindow(m_xContext->getValueByName( 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogParentWindow"))) 
,uno::UNO_QUERY);
+        const uno::Reference< report::XReportControlFormat> 
xReportControlFormat(m_xReportComponent,uno::UNO_QUERY);
         aGuard.clear();
 
         uno::Sequence< beans::NamedValue > aFontSettings;
@@ -1566,7 +1564,7 @@
             return false;
         }
 
-        String aGcc3WorkaroundTemporary( ModuleRes(RID_STR_FILTER));
+        const String aGcc3WorkaroundTemporary( ModuleRes(RID_STR_FILTER));
         const ::rtl::OUString sPropertyUIName( aGcc3WorkaroundTemporary );
         // initialize the dialog
         uno::Reference< beans::XPropertySet > xDialogProps( xDialog, 
uno::UNO_QUERY_THROW );
@@ -1597,8 +1595,8 @@
 void GeometryHandler::checkPosAndSize(  const awt::Point& _aNewPos,
                                     const awt::Size& _aSize)
 {
-    uno::Reference< report::XReportComponent> 
xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY);
-    uno::Reference< report::XSection> 
xSection(xSourceReportComponent->getParent(),uno::UNO_QUERY);
+    const uno::Reference< report::XReportComponent> 
xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY);
+    const uno::Reference< report::XSection> 
xSection(xSourceReportComponent->getParent(),uno::UNO_QUERY);
     if ( !xSection.is() || uno::Reference< 
report::XShape>(xSourceReportComponent,uno::UNO_QUERY).is() ) // shapes can 
overlap.
         return;
     
@@ -1608,14 +1606,14 @@
 
     ::Rectangle aSourceRect(aPos,VCLSize(_aSize));
 
-    sal_Int32 nCount = xSection->getCount();
+    const sal_Int32 nCount = xSection->getCount();
     for (sal_Int32 i = 0; i < nCount ; ++i)
     {
-        uno::Reference< report::XReportComponent> 
xReportComponent(xSection->getByIndex(i),uno::UNO_QUERY);
+        const uno::Reference< report::XReportComponent> 
xReportComponent(xSection->getByIndex(i),uno::UNO_QUERY);
         if ( xReportComponent.is() && xReportComponent != 
xSourceReportComponent )
         {
-            ::Rectangle 
aBoundRect(VCLPoint(xReportComponent->getPosition()),VCLSize(xReportComponent->getSize()));
-            ::Rectangle aRect = aSourceRect.GetIntersection(aBoundRect);
+            const ::Rectangle 
aBoundRect(VCLPoint(xReportComponent->getPosition()),VCLSize(xReportComponent->getSize()));
+            const ::Rectangle aRect = aSourceRect.GetIntersection(aBoundRect);
             if ( !aRect.IsEmpty() && (aRect.Left() != aRect.Right() && 
aRect.Top() != aRect.Bottom() ) )
                 throw beans::PropertyVetoException(String(ModuleRes( 
RID_STR_OVERLAP_OTHER_CONTROL)),xSourceReportComponent);
         }
@@ -1688,7 +1686,7 @@
     return sReturn.makeStringAndClear();
 }
 // 
-----------------------------------------------------------------------------
-uno::Reference< report::XFunctionsSupplier> GeometryHandler::fillScope_throw()
+uno::Reference< report::XFunctionsSupplier> 
GeometryHandler::fillScope_throw(::rtl::OUString& _rsNamePostFix)
 {
     uno::Reference< report::XFunctionsSupplier> xReturn;
 
@@ -1701,18 +1699,36 @@
         if ( xGroup.is() )
         {
             String sGroupName = String(ModuleRes(RID_STR_SCOPE_GROUP));
-            sGroupName.SearchAndReplaceAscii("%1",xGroup->getExpression());
+            _rsNamePostFix = xGroup->getExpression();
+            sGroupName.SearchAndReplaceAscii("%1",_rsNamePostFix);
             m_sScope = sGroupName;
             xReturn = xGroup.get();
         }
-        else
+        else if ( xSection == xReportDefinition->getDetail() )
+        {
+            const uno::Reference< report::XGroups> xGroups = 
xReportDefinition->getGroups();
+            const sal_Int32 nCount = xGroups->getCount();
+            if ( nCount )
+            {
+                const uno::Reference< report::XGroup> 
xGroup(xGroups->getByIndex(nCount - 1),uno::UNO_QUERY_THROW);
+                String sGroupName = String(ModuleRes(RID_STR_SCOPE_GROUP));
+                _rsNamePostFix = xGroup->getExpression();
+                sGroupName.SearchAndReplaceAscii("%1",_rsNamePostFix);
+                m_sScope = sGroupName;                
+                xReturn = xGroup.get();
+            }
+        }
+        if ( !m_sScope.getLength() )
         {
             xReturn = xReportDefinition.get();
-            m_sScope = xReportDefinition->getName();
+            _rsNamePostFix = m_sScope = xReportDefinition->getName();
         }
     }
     else if ( m_sScope == xReportDefinition->getName() )
+    {
         xReturn = xReportDefinition.get();
+        _rsNamePostFix = m_sScope;
+    }
     else
     {
         uno::Reference< report::XGroups> xGroups = 
xReportDefinition->getGroups();
@@ -1725,6 +1741,7 @@
             sGroupName.SearchAndReplaceAscii("%1",xGroup->getExpression());
             if ( m_sScope == ::rtl::OUString(sGroupName) )
             {
+                _rsNamePostFix = xGroup->getExpression();
                 xReturn = xGroup.get();
                 break;
             }
@@ -1741,29 +1758,66 @@
     return m_sDefaultFunction;
 }
 // 
-----------------------------------------------------------------------------
-sal_Bool GeometryHandler::isDefaultFunction(const ::rtl::OUString& 
_sFunction,::rtl::OUString& _rDataField,bool _bSet) const
+sal_Bool GeometryHandler::isDefaultFunction( const ::rtl::OUString& 
_sQuotedFunction
+                                            ,::rtl::OUString& _rDataField
+                                            ,const uno::Reference< 
report::XFunctionsSupplier>& _xFunctionsSupplier
+                                            ,bool _bSet) const
 {
     sal_Bool bDefaultFunction = sal_False;
     try
     {
         const uno::Reference< report::XReportComponent> 
xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY_THROW);
         const uno::Reference< report::XSection> 
xSection(xSourceReportComponent->getParent(),uno::UNO_QUERY_THROW);
-
         const uno::Reference< report::XReportDefinition> xReportDefinition = 
xSection->getReportDefinition();
-        const uno::Reference< report::XGroups> xGroups = 
xReportDefinition->getGroups();
-        uno::Reference< report::XFunctionsSupplier> xFunctionSup = 
xSection->getGroup().get();
-        if ( !xFunctionSup.is() && xSection == xReportDefinition->getDetail() )
-            xFunctionSup = xReportDefinition.get();
 
-        ::std::pair<TFunctions::const_iterator,TFunctions::const_iterator> 
aFind = m_aFunctionNames.equal_range(_sFunction);
+        ::std::pair<TFunctions::const_iterator,TFunctions::const_iterator> 
aFind = m_aFunctionNames.equal_range(_sQuotedFunction);
         while ( aFind.first != aFind.second )
         {
-            if ( aFind.first->second.second == xFunctionSup )
+            if ( !_xFunctionsSupplier.is() || _xFunctionsSupplier == 
aFind.first->second.second )
             {
-                beans::Optional< ::rtl::OUString> aInitalFormula = 
aFind.first->second.first->getInitialFormula();
+                const beans::Optional< ::rtl::OUString> aInitalFormula = 
aFind.first->second.first->getInitialFormula();
                 if ( aInitalFormula.IsPresent )
                 {
-                    const String sFormula( 
aFind.first->second.first->getFormula() );
+                    ::rtl::OUString sDefaultFunctionName;
+                    bDefaultFunction = 
impl_isDefaultFunction_nothrow(aFind.first->second.first,_rDataField,sDefaultFunctionName);
+                    if ( bDefaultFunction )
+                    {
+                        m_xFunction = aFind.first->second.first;
+                        if ( _bSet )
+                        {
+                            m_sDefaultFunction = sDefaultFunctionName;
+                            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());
+                                m_sScope = sGroupName;
+                            }
+                            else
+                                m_sScope = xReportDefinition->getName();
+                        }
+                    }
+                    break;
+                }
+            }
+            ++(aFind.first);
+        }
+    }
+    catch(uno::Exception&)
+    {
+        OSL_ENSURE(0,"Exception caught!");
+    }
+    return bDefaultFunction;
+}
+// 
-----------------------------------------------------------------------------
+sal_Bool GeometryHandler::impl_isDefaultFunction_nothrow( const 
uno::Reference< report::XFunction>& _xFunction
+                                            ,::rtl::OUString& _rDataField
+                                            ,::rtl::OUString& 
_rsDefaultFunctionName) const
+{
+    sal_Bool bDefaultFunction = sal_False;
+    try
+    {
+        const String sFormula( _xFunction->getFormula() );
                     util::SearchOptions aSearchOptions;
                     aSearchOptions.algorithmType = 
util::SearchAlgorithms_REGEXP;
                     aSearchOptions.searchFlag = 0x00000100;
@@ -1782,30 +1836,12 @@
                             aDataSearch.SearchFrwrd(sFormula,&start,&end );
                             ++start;
                             _rDataField = sFormula.Copy(start,end-start-1);
-                            m_xFunction = aFind.first->second.first;
-                            if ( _bSet )
-                            {
-                                m_sDefaultFunction = aIter->m_sName;
-                                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());
-                                    m_sScope = sGroupName;
-                                }
-                                else
-                                    m_sScope = xReportDefinition->getName();
-                            }
+                _rsDefaultFunctionName = aIter->m_sName;
                             break;
                         }
                     }
                     
                     bDefaultFunction = aIter != aDeEnd;
-                    break;
-                }
-            }            
-            ++(aFind.first);
-        }
     }
     catch(uno::Exception&)
     {
@@ -1866,27 +1902,35 @@
 {
     try
     {
+        ::rtl::OUString sNamePostFix;
+        const uno::Reference< report::XFunctionsSupplier> xFunctionsSupplier = 
fillScope_throw(sNamePostFix);
+
         ::std::vector< DefaultFunction >::const_iterator aIter = 
m_aDefaultFunctions.begin();
         ::std::vector< DefaultFunction >::const_iterator aDeEnd = 
m_aDefaultFunctions.end();
         for (; aIter != aDeEnd; ++aIter)
         {
             if ( aIter->m_sName == _sFunction )
             {
-                const ::rtl::OUString sFunctionName( _sFunction + _sDataField 
);
+                const ::rtl::OUString sFunctionName( _sFunction + _sDataField 
+ sNamePostFix);
                 const ::rtl::OUString 
sQuotedFunctionName(lcl_getQuotedFunctionName(sFunctionName));
 
                 beans::PropertyChangeEvent aEvent;
                 aEvent.PropertyName = PROPERTY_SCOPE;
                 aEvent.OldValue <<= m_sScope;
 
-                TFunctions::const_iterator aFind = 
m_aFunctionNames.find(sQuotedFunctionName);
-                if ( aFind != m_aFunctionNames.end() )
+                
::std::pair<TFunctions::const_iterator,TFunctions::const_iterator> aFind = 
m_aFunctionNames.equal_range(sQuotedFunctionName);
+                while ( aFind.first != aFind.second )
                 {
-                    m_xFunction = aFind->second.first;
+                    if ( xFunctionsSupplier == aFind.first->second.second )
+                    {
+                        m_xFunction = aFind.first->second.first;
                     ::rtl::OUString sTemp;
-                    isDefaultFunction(sQuotedFunctionName,sTemp,true); // 
implicitly sets the m_sScope
+                        
isDefaultFunction(sQuotedFunctionName,sTemp,uno::Reference< 
report::XFunctionsSupplier>(),true); // implicitly sets the m_sScope
+                        break;
                 }
-                else
+                    ++(aFind.first);
+                }
+                if ( aFind.first == aFind.second )
                     impl_createFunction(sFunctionName,_sDataField,*aIter);
 
                 OBlocker aBlocker(m_bIn);
@@ -1994,9 +2038,9 @@
     }
 }
 // 
-----------------------------------------------------------------------------
-bool GeometryHandler::impl_isCounterFunction_throw(const ::rtl::OUString& 
_sFunctionName,::rtl::OUString& _Out_sScope) const
+bool GeometryHandler::impl_isCounterFunction_throw(const ::rtl::OUString& 
_sQuotedFunctionName,::rtl::OUString& _Out_sScope) const
 {
-    ::std::pair<TFunctions::const_iterator,TFunctions::const_iterator> aFind = 
m_aFunctionNames.equal_range(_sFunctionName);
+    ::std::pair<TFunctions::const_iterator,TFunctions::const_iterator> aFind = 
m_aFunctionNames.equal_range(_sQuotedFunctionName);
     while ( aFind.first != aFind.second )
     {
         const beans::Optional< ::rtl::OUString> aInitalFormula = 
aFind.first->second.first->getInitialFormula();
@@ -2012,7 +2056,7 @@
             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);
+                const uno::Reference< report::XGroup > 
xGroup(aFind.first->second.second,uno::UNO_QUERY);
                 if ( xGroup.is() )
                 {
                     String sGroupName = String(ModuleRes(RID_STR_SCOPE_GROUP));
@@ -2056,20 +2100,42 @@
         aInitialFormula.Value = sInitialFormula;
         m_xFunction->setInitialFormula( aInitialFormula );
     }
-    const uno::Reference< report::XFunctionsSupplier> xFunctionsSupplier = 
fillScope_throw();
+    ::rtl::OUString sNamePostFix;
+    const uno::Reference< report::XFunctionsSupplier> xFunctionsSupplier = 
fillScope_throw(sNamePostFix);
     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;
 }
 // 
-----------------------------------------------------------------------------
-sal_uInt32 GeometryHandler::impl_getDataFieldType_throw() const
+void GeometryHandler::impl_setCounterFunction_throw()
+{
+    ::rtl::OUString sNamePostFix;
+    fillScope_throw(sNamePostFix);
+    ::rtl::OUString sFunctionName = m_aCounterFunction.m_sName;
+    sFunctionName += sNamePostFix;
+    const ::rtl::OUString sQuotedFunctionName = 
lcl_getQuotedFunctionName(sFunctionName);
+    ::rtl::OUString sScope;
+    if ( !(sFunctionName.getLength() && 
m_aFunctionNames.find(sQuotedFunctionName) != m_aFunctionNames.end() && 
impl_isCounterFunction_throw(sQuotedFunctionName,sScope)) )
+        
impl_createFunction(sFunctionName,::rtl::OUString(),m_aCounterFunction);
+    
+    OBlocker aBlocker(m_bIn);
+    
m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny(impl_convertToFormula(
 uno::makeAny(sQuotedFunctionName))));
+}
+// 
-----------------------------------------------------------------------------
+sal_uInt32 GeometryHandler::impl_getDataFieldType_throw(const ::rtl::OUString& 
_sDataField) const
 {
     sal_uInt32 nDataFieldType = UNDEF_DATA;
-    uno::Any aDataField = m_xReportComponent->getPropertyValue( 
PROPERTY_DATAFIELD );
-    lcl_convertFormulaTo(aDataField,aDataField);
     ::rtl::OUString sDataField;
+    if ( _sDataField.getLength() )
+        sDataField = _sDataField;
+    else
+    {
+        uno::Any aDataField( m_xReportComponent->getPropertyValue( 
PROPERTY_DATAFIELD ) );
+        lcl_convertFormulaTo(aDataField,aDataField);
     aDataField >>= sDataField;
+    }
+    
     if ( sDataField.getLength() )
     {
         if ( impl_isDataField(sDataField) )
@@ -2113,7 +2179,7 @@
         switch(m_nDataFieldType)
         {
             case FUNCTION:
-                isDefaultFunction(sDataField,sDataField,true);
+                isDefaultFunction(sDataField,sDataField,uno::Reference< 
report::XFunctionsSupplier>(),true);
                 break;
             case COUNTER:
                 impl_isCounterFunction_throw(sDataField,m_sScope);
@@ -2125,7 +2191,6 @@
         
resetOwnProperties(aGuard,sOldFunctionName,sOldScope,nOldDataFieldType);
     }
 }
-
 //........................................................................
 } // namespace rptui
 //........................................................................




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

Reply via email to