diff options
author | Sascha Ballach <sab@openoffice.org> | 2001-04-04 03:25:00 +0000 |
---|---|---|
committer | Sascha Ballach <sab@openoffice.org> | 2001-04-04 03:25:00 +0000 |
commit | 25c1dd23ac4f0d1aba08d9a8facfcf571eeeb053 (patch) | |
tree | 8b61620356db800fd39badfe29b32f5c18cc96fd /sc | |
parent | 3a4e0ff8ef387a473a932ad92412be71532119ed (diff) |
#79771#; implement a better getPropertyStates
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/cellsuno.hxx | 8 | ||||
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 132 |
2 files changed, 89 insertions, 51 deletions
diff --git a/sc/inc/cellsuno.hxx b/sc/inc/cellsuno.hxx index 2fdf5074d208..ffebbd015733 100644 --- a/sc/inc/cellsuno.hxx +++ b/sc/inc/cellsuno.hxx @@ -2,9 +2,9 @@ * * $RCSfile: cellsuno.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: nn $ $Date: 2000-12-18 19:28:07 $ + * last change: $Author: sab $ $Date: 2001-04-04 04:23:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -288,6 +288,10 @@ private: com::sun::star::util::XSearchDescriptor>& xDesc, const ScAddress* pLastPos); + ::com::sun::star::beans::PropertyState SAL_CALL GetPropertyState( + USHORT nWhich, + const String& PropertyName ); + public: ScCellRangesBase(); // fuer SMART_REFLECTION Krempel ScCellRangesBase(ScDocShell* pDocSh, const ScRange& rR); diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 0190042cc575..5c839d48dcd6 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cellsuno.cxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: nn $ $Date: 2001-03-23 09:53:43 $ + * last change: $Author: sab $ $Date: 2001-04-04 04:25:00 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1414,14 +1414,13 @@ void SAL_CALL ScCellRangesBase::clearContents( sal_Int32 nContentFlags ) throw(u // XPropertyState -USHORT lcl_GetPropertyWhich( const String& rName ) +USHORT lcl_GetPropertyWhich(const String& rName) { // Which-ID des betroffenen Items, auch wenn das Item die Property // nicht alleine behandeln kann - USHORT nWhich = 0; - const SfxItemPropertyMap* pMap = - SfxItemPropertyMap::GetByName( lcl_GetCellsPropertyMap(), rName ); + USHORT nWhich(0); + const SfxItemPropertyMap* pMap = SfxItemPropertyMap::GetByName(lcl_GetCellsPropertyMap(), rName ); if ( pMap && pMap->nWID ) nWhich = pMap->nWID; else if ( rName.EqualsAscii( SC_UNONAME_TBLBORD ) ) @@ -1435,59 +1434,86 @@ USHORT lcl_GetPropertyWhich( const String& rName ) return nWhich; } -beans::PropertyState SAL_CALL ScCellRangesBase::getPropertyState( const rtl::OUString& aPropertyName ) - throw(beans::UnknownPropertyException, uno::RuntimeException) +const SfxItemPropertyMap* lcl_GetPropertyWhich(const SfxItemPropertyMap* pMap, const String& rName, USHORT& nWhich ) { - ScUnoGuard aGuard; - if ( aRanges.Count() == 0 ) - throw uno::RuntimeException(); + // Which-ID des betroffenen Items, auch wenn das Item die Property + // nicht alleine behandeln kann + const SfxItemPropertyMap* pRetMap = SfxItemPropertyMap::GetByName(pMap, rName ); + if ( pRetMap && pRetMap->nWID ) + nWhich = pRetMap->nWID; + else if ( rName.EqualsAscii( SC_UNONAME_TBLBORD ) ) + nWhich = ATTR_BORDER; + else if ( rName.EqualsAscii( SC_UNONAME_CONDFMT ) || rName.EqualsAscii( SC_UNONAME_CONDLOC ) || + rName.EqualsAscii( SC_UNONAME_CONDXML ) ) + nWhich = ATTR_CONDITIONAL; + else if ( rName.EqualsAscii( SC_UNONAME_VALIDAT ) || rName.EqualsAscii( SC_UNONAME_VALILOC ) || + rName.EqualsAscii( SC_UNONAME_VALIXML ) ) + nWhich = ATTR_VALIDDATA; + return pRetMap; +} + +beans::PropertyState SAL_CALL ScCellRangesBase::GetPropertyState(USHORT nWhich, const String& aNameString) +{ beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE; - if ( pDocShell ) + if ( nWhich ) // irgendwie zustandegekommene Which-ID { - String aNameString = aPropertyName; - USHORT nWhich = lcl_GetPropertyWhich( aNameString ); + //! Bei Items, die mehrere Properties enthalten (z.B. Hintergrund) + //! wird hier evtl. zu oft "Ambiguous" zurueckgegeben - if ( nWhich ) // irgendwie zustandegekommene Which-ID + // for PropertyState, don't look at styles + const ScPatternAttr* pPattern = GetCurrentAttrsFlat(); + if ( pPattern ) { - //! Bei Items, die mehrere Properties enthalten (z.B. Hintergrund) - //! wird hier evtl. zu oft "Ambiguous" zurueckgegeben + SfxItemState eState = pPattern->GetItemSet().GetItemState( nWhich, FALSE ); - // for PropertyState, don't look at styles - const ScPatternAttr* pPattern = GetCurrentAttrsFlat(); - if ( pPattern ) - { - SfxItemState eState = pPattern->GetItemSet().GetItemState( nWhich, FALSE ); - - // if no rotate value is set, look at orientation - //! also for a fixed value of 0 (in case orientation is ambiguous)? - if ( nWhich == ATTR_ROTATE_VALUE && eState == SFX_ITEM_DEFAULT ) - eState = pPattern->GetItemSet().GetItemState( ATTR_ORIENTATION, FALSE ); - - if ( eState == SFX_ITEM_SET ) - eRet = beans::PropertyState_DIRECT_VALUE; - else if ( eState == SFX_ITEM_DEFAULT ) - eRet = beans::PropertyState_DEFAULT_VALUE; - else if ( eState == SFX_ITEM_DONTCARE ) - eRet = beans::PropertyState_AMBIGUOUS_VALUE; - else - DBG_ERROR("unbekannter ItemState"); - } - } - else if ( aNameString.EqualsAscii( SC_UNONAME_CHCOLHDR ) || aNameString.EqualsAscii( SC_UNONAME_CHROWHDR ) ) - eRet = beans::PropertyState_DIRECT_VALUE; - else if ( aNameString.EqualsAscii( SC_UNONAME_CELLSTYL ) ) - { - // a style is always set, there's no default state - ScMarkData aMark; - aMark.MarkFromRangeList( aRanges, FALSE ); - const ScStyleSheet* pStyle = pDocShell->GetDocument()->GetSelectionStyle(aMark); - if (pStyle) + // if no rotate value is set, look at orientation + //! also for a fixed value of 0 (in case orientation is ambiguous)? + if ( nWhich == ATTR_ROTATE_VALUE && eState == SFX_ITEM_DEFAULT ) + eState = pPattern->GetItemSet().GetItemState( ATTR_ORIENTATION, FALSE ); + + if ( eState == SFX_ITEM_SET ) eRet = beans::PropertyState_DIRECT_VALUE; - else + else if ( eState == SFX_ITEM_DEFAULT ) + eRet = beans::PropertyState_DEFAULT_VALUE; + else if ( eState == SFX_ITEM_DONTCARE ) eRet = beans::PropertyState_AMBIGUOUS_VALUE; + else + DBG_ERROR("unbekannter ItemState"); } } + else if ( aNameString.EqualsAscii( SC_UNONAME_CHCOLHDR ) || aNameString.EqualsAscii( SC_UNONAME_CHROWHDR ) ) + eRet = beans::PropertyState_DIRECT_VALUE; + else if ( aNameString.EqualsAscii( SC_UNONAME_CELLSTYL ) ) + { + // a style is always set, there's no default state + ScMarkData aMark; + aMark.MarkFromRangeList( aRanges, FALSE ); + const ScStyleSheet* pStyle = pDocShell->GetDocument()->GetSelectionStyle(aMark); + if (pStyle) + eRet = beans::PropertyState_DIRECT_VALUE; + else + eRet = beans::PropertyState_AMBIGUOUS_VALUE; + } + return eRet; +} + +beans::PropertyState SAL_CALL ScCellRangesBase::getPropertyState( const rtl::OUString& aPropertyName ) + throw(beans::UnknownPropertyException, uno::RuntimeException) +{ + ScUnoGuard aGuard; + if ( aRanges.Count() == 0 ) + throw uno::RuntimeException(); + + beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE; + if ( pDocShell ) + { + String aNameString (aPropertyName); + const SfxItemPropertyMap* pMap = lcl_GetCellsPropertyMap(); + USHORT nWhich(0); + pMap = lcl_GetPropertyWhich(pMap, aNameString, nWhich); + GetPropertyState(nWhich, aPropertyName); + } return eRet; } @@ -1503,8 +1529,16 @@ uno::Sequence<beans::PropertyState> SAL_CALL ScCellRangesBase::getPropertyStates const rtl::OUString* pNames = aPropertyNames.getConstArray(); uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength()); beans::PropertyState* pStates = aRet.getArray(); + const SfxItemPropertyMap* pMap = lcl_GetCellsPropertyMap(); for(INT32 i = 0; i < aPropertyNames.getLength(); i++) - pStates[i] = getPropertyState(pNames[i]); + { + USHORT nWhich(0); + String aNameString(aPropertyNames[i]); + pMap = lcl_GetPropertyWhich(pMap, aNameString, nWhich); + pStates[i] = GetPropertyState(nWhich, aNameString); + if (!pMap) + pMap = lcl_GetCellsPropertyMap(); + } return aRet; } |