1*b3f79822SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b3f79822SAndrew Rist * distributed with this work for additional information 6*b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b3f79822SAndrew Rist * "License"); you may not use this file except in compliance 9*b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b3f79822SAndrew Rist * software distributed under the License is distributed on an 15*b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b3f79822SAndrew Rist * KIND, either express or implied. See the License for the 17*b3f79822SAndrew Rist * specific language governing permissions and limitations 18*b3f79822SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*b3f79822SAndrew Rist *************************************************************/ 21*b3f79822SAndrew Rist 22*b3f79822SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sc.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <editeng/memberids.hrc> 29cdf0e10cSrcweir #include <svl/smplhint.hxx> 30cdf0e10cSrcweir #include <svl/itemprop.hxx> 31cdf0e10cSrcweir #include <svx/unomid.hxx> 32cdf0e10cSrcweir #include <i18npool/mslangid.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include "scitems.hxx" 37cdf0e10cSrcweir #include "defltuno.hxx" 38cdf0e10cSrcweir #include "miscuno.hxx" 39cdf0e10cSrcweir #include "docsh.hxx" 40cdf0e10cSrcweir #include "docpool.hxx" 41cdf0e10cSrcweir #include "unoguard.hxx" 42cdf0e10cSrcweir #include "unonames.hxx" 43cdf0e10cSrcweir #include "docoptio.hxx" 44cdf0e10cSrcweir 45cdf0e10cSrcweir #include <limits> 46cdf0e10cSrcweir 47cdf0e10cSrcweir using namespace ::com::sun::star; 48cdf0e10cSrcweir 49cdf0e10cSrcweir //------------------------------------------------------------------------ 50cdf0e10cSrcweir 51cdf0e10cSrcweir const SfxItemPropertyMapEntry* lcl_GetDocDefaultsMap() 52cdf0e10cSrcweir { 53cdf0e10cSrcweir static SfxItemPropertyMapEntry aDocDefaultsMap_Impl[] = 54cdf0e10cSrcweir { 55cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET }, 56cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET }, 57cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET }, 58cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY }, 59cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY }, 60cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY }, 61cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME }, 62cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME }, 63cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME }, 64cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH }, 65cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH }, 66cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH }, 67cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME }, 68cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME }, 69cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME }, 70cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE }, 71cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE }, 72cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE }, 73cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_STANDARDDEC), 0, &getCppuType((sal_Int16*)0), 0, 0 }, 74cdf0e10cSrcweir {MAP_CHAR_LEN(SC_UNO_TABSTOPDIS), 0, &getCppuType((sal_Int32*)0), 0, 0 }, 75cdf0e10cSrcweir {0,0,0,0,0,0} 76cdf0e10cSrcweir }; 77cdf0e10cSrcweir return aDocDefaultsMap_Impl; 78cdf0e10cSrcweir } 79cdf0e10cSrcweir 80cdf0e10cSrcweir inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; } 81cdf0e10cSrcweir inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; } 82cdf0e10cSrcweir inline long TwipsToEvenHMM(long nTwips) { return ( (nTwips * 127 + 72) / 144 ) * 2; } 83cdf0e10cSrcweir 84cdf0e10cSrcweir //------------------------------------------------------------------------ 85cdf0e10cSrcweir 86cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScDocDefaultsObj, "ScDocDefaultsObj", "com.sun.star.sheet.Defaults" ) 87cdf0e10cSrcweir 88cdf0e10cSrcweir //------------------------------------------------------------------------ 89cdf0e10cSrcweir 90cdf0e10cSrcweir ScDocDefaultsObj::ScDocDefaultsObj(ScDocShell* pDocSh) : 91cdf0e10cSrcweir pDocShell( pDocSh ), 92cdf0e10cSrcweir aPropertyMap(lcl_GetDocDefaultsMap()) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir pDocShell->GetDocument()->AddUnoObject(*this); 95cdf0e10cSrcweir } 96cdf0e10cSrcweir 97cdf0e10cSrcweir ScDocDefaultsObj::~ScDocDefaultsObj() 98cdf0e10cSrcweir { 99cdf0e10cSrcweir if (pDocShell) 100cdf0e10cSrcweir pDocShell->GetDocument()->RemoveUnoObject(*this); 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir void ScDocDefaultsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir if ( rHint.ISA( SfxSimpleHint ) && 106cdf0e10cSrcweir ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir pDocShell = NULL; // document gone 109cdf0e10cSrcweir } 110cdf0e10cSrcweir } 111cdf0e10cSrcweir 112cdf0e10cSrcweir void ScDocDefaultsObj::ItemsChanged() 113cdf0e10cSrcweir { 114cdf0e10cSrcweir if (pDocShell) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir //! if not in XML import, adjust row heights 117cdf0e10cSrcweir 118cdf0e10cSrcweir pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID ); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir // XPropertySet 123cdf0e10cSrcweir 124cdf0e10cSrcweir uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDocDefaultsObj::getPropertySetInfo() 125cdf0e10cSrcweir throw(uno::RuntimeException) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir ScUnoGuard aGuard; 128cdf0e10cSrcweir static uno::Reference<beans::XPropertySetInfo> aRef = new SfxItemPropertySetInfo( 129cdf0e10cSrcweir &aPropertyMap ); 130cdf0e10cSrcweir return aRef; 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir void SAL_CALL ScDocDefaultsObj::setPropertyValue( 134cdf0e10cSrcweir const rtl::OUString& aPropertyName, const uno::Any& aValue ) 135cdf0e10cSrcweir throw(beans::UnknownPropertyException, beans::PropertyVetoException, 136cdf0e10cSrcweir lang::IllegalArgumentException, lang::WrappedTargetException, 137cdf0e10cSrcweir uno::RuntimeException) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir ScUnoGuard aGuard; 140cdf0e10cSrcweir 141cdf0e10cSrcweir if ( !pDocShell ) 142cdf0e10cSrcweir throw uno::RuntimeException(); 143cdf0e10cSrcweir 144cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = aPropertyMap.getByName( aPropertyName ); 145cdf0e10cSrcweir if ( !pEntry ) 146cdf0e10cSrcweir throw beans::UnknownPropertyException(); 147cdf0e10cSrcweir if(!pEntry->nWID) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir if(aPropertyName.compareToAscii(SC_UNO_STANDARDDEC) == 0) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 152cdf0e10cSrcweir if (pDoc) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir ScDocOptions aDocOpt(pDoc->GetDocOptions()); 155cdf0e10cSrcweir sal_Int16 nValue = 0; 156cdf0e10cSrcweir if (aValue >>= nValue) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir aDocOpt.SetStdPrecision(static_cast<sal_uInt16> (nValue)); 159cdf0e10cSrcweir pDoc->SetDocOptions(aDocOpt); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir } 162cdf0e10cSrcweir else 163cdf0e10cSrcweir throw uno::RuntimeException(); 164cdf0e10cSrcweir } 165cdf0e10cSrcweir else if (aPropertyName.compareToAscii(SC_UNO_TABSTOPDIS) == 0) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 168cdf0e10cSrcweir if (pDoc) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir ScDocOptions aDocOpt(pDoc->GetDocOptions()); 171cdf0e10cSrcweir sal_Int32 nValue = 0; 172cdf0e10cSrcweir if (aValue >>= nValue) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir aDocOpt.SetTabDistance(static_cast<sal_uInt16>(HMMToTwips(nValue))); 175cdf0e10cSrcweir pDoc->SetDocOptions(aDocOpt); 176cdf0e10cSrcweir } 177cdf0e10cSrcweir } 178cdf0e10cSrcweir else 179cdf0e10cSrcweir throw uno::RuntimeException(); 180cdf0e10cSrcweir } 181cdf0e10cSrcweir } 182cdf0e10cSrcweir else if ( pEntry->nWID == ATTR_FONT_LANGUAGE || 183cdf0e10cSrcweir pEntry->nWID == ATTR_CJK_FONT_LANGUAGE || 184cdf0e10cSrcweir pEntry->nWID == ATTR_CTL_FONT_LANGUAGE ) 185cdf0e10cSrcweir { 186cdf0e10cSrcweir // for getPropertyValue the PoolDefaults are sufficient, 187cdf0e10cSrcweir // but setPropertyValue has to be handled differently 188cdf0e10cSrcweir 189cdf0e10cSrcweir lang::Locale aLocale; 190cdf0e10cSrcweir if ( aValue >>= aLocale ) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir LanguageType eNew; 193cdf0e10cSrcweir if (aLocale.Language.getLength() || aLocale.Country.getLength()) 194cdf0e10cSrcweir eNew = MsLangId::convertLocaleToLanguage( aLocale ); 195cdf0e10cSrcweir else 196cdf0e10cSrcweir eNew = LANGUAGE_NONE; 197cdf0e10cSrcweir 198cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 199cdf0e10cSrcweir LanguageType eLatin, eCjk, eCtl; 200cdf0e10cSrcweir pDoc->GetLanguage( eLatin, eCjk, eCtl ); 201cdf0e10cSrcweir 202cdf0e10cSrcweir if ( pEntry->nWID == ATTR_CJK_FONT_LANGUAGE ) 203cdf0e10cSrcweir eCjk = eNew; 204cdf0e10cSrcweir else if ( pEntry->nWID == ATTR_CTL_FONT_LANGUAGE ) 205cdf0e10cSrcweir eCtl = eNew; 206cdf0e10cSrcweir else 207cdf0e10cSrcweir eLatin = eNew; 208cdf0e10cSrcweir 209cdf0e10cSrcweir pDoc->SetLanguage( eLatin, eCjk, eCtl ); 210cdf0e10cSrcweir } 211cdf0e10cSrcweir } 212cdf0e10cSrcweir else 213cdf0e10cSrcweir { 214cdf0e10cSrcweir ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool(); 215cdf0e10cSrcweir SfxPoolItem* pNewItem = pPool->GetDefaultItem(pEntry->nWID).Clone(); 216cdf0e10cSrcweir 217cdf0e10cSrcweir if( !pNewItem->PutValue( aValue, pEntry->nMemberId ) ) 218cdf0e10cSrcweir throw lang::IllegalArgumentException(); 219cdf0e10cSrcweir 220cdf0e10cSrcweir pPool->SetPoolDefaultItem( *pNewItem ); 221cdf0e10cSrcweir delete pNewItem; // copied in SetPoolDefaultItem 222cdf0e10cSrcweir 223cdf0e10cSrcweir ItemsChanged(); 224cdf0e10cSrcweir } 225cdf0e10cSrcweir } 226cdf0e10cSrcweir 227cdf0e10cSrcweir uno::Any SAL_CALL ScDocDefaultsObj::getPropertyValue( const rtl::OUString& aPropertyName ) 228cdf0e10cSrcweir throw(beans::UnknownPropertyException, lang::WrappedTargetException, 229cdf0e10cSrcweir uno::RuntimeException) 230cdf0e10cSrcweir { 231cdf0e10cSrcweir // use pool default if set 232cdf0e10cSrcweir 233cdf0e10cSrcweir ScUnoGuard aGuard; 234cdf0e10cSrcweir 235cdf0e10cSrcweir if ( !pDocShell ) 236cdf0e10cSrcweir throw uno::RuntimeException(); 237cdf0e10cSrcweir 238cdf0e10cSrcweir uno::Any aRet; 239cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = aPropertyMap.getByName( aPropertyName ); 240cdf0e10cSrcweir if ( !pEntry ) 241cdf0e10cSrcweir throw beans::UnknownPropertyException(); 242cdf0e10cSrcweir 243cdf0e10cSrcweir if (!pEntry->nWID) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir if(aPropertyName.compareToAscii(SC_UNO_STANDARDDEC) == 0) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 248cdf0e10cSrcweir if (pDoc) 249cdf0e10cSrcweir { 250cdf0e10cSrcweir const ScDocOptions& aDocOpt = pDoc->GetDocOptions(); 251cdf0e10cSrcweir sal_uInt16 nPrec = aDocOpt.GetStdPrecision(); 252cdf0e10cSrcweir // the max value of unsigned 16-bit integer is used as the flag 253cdf0e10cSrcweir // value for unlimited precision, c.f. 254cdf0e10cSrcweir // SvNumberFormatter::UNLIMITED_PRECISION. 255cdf0e10cSrcweir if (nPrec <= ::std::numeric_limits<sal_Int16>::max()) 256cdf0e10cSrcweir aRet <<= static_cast<sal_Int16> (nPrec); 257cdf0e10cSrcweir } 258cdf0e10cSrcweir else 259cdf0e10cSrcweir throw uno::RuntimeException(); 260cdf0e10cSrcweir } 261cdf0e10cSrcweir else if (aPropertyName.compareToAscii(SC_UNO_TABSTOPDIS) == 0) 262cdf0e10cSrcweir { 263cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 264cdf0e10cSrcweir if (pDoc) 265cdf0e10cSrcweir { 266cdf0e10cSrcweir const ScDocOptions& aDocOpt = pDoc->GetDocOptions(); 267cdf0e10cSrcweir sal_Int32 nValue (TwipsToEvenHMM(aDocOpt.GetTabDistance())); 268cdf0e10cSrcweir aRet <<= nValue; 269cdf0e10cSrcweir } 270cdf0e10cSrcweir else 271cdf0e10cSrcweir throw uno::RuntimeException(); 272cdf0e10cSrcweir } 273cdf0e10cSrcweir } 274cdf0e10cSrcweir else 275cdf0e10cSrcweir { 276cdf0e10cSrcweir ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool(); 277cdf0e10cSrcweir const SfxPoolItem& rItem = pPool->GetDefaultItem( pEntry->nWID ); 278cdf0e10cSrcweir rItem.QueryValue( aRet, pEntry->nMemberId ); 279cdf0e10cSrcweir } 280cdf0e10cSrcweir return aRet; 281cdf0e10cSrcweir } 282cdf0e10cSrcweir 283cdf0e10cSrcweir SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDocDefaultsObj ) 284cdf0e10cSrcweir 285cdf0e10cSrcweir // XPropertyState 286cdf0e10cSrcweir 287cdf0e10cSrcweir beans::PropertyState SAL_CALL ScDocDefaultsObj::getPropertyState( const rtl::OUString& aPropertyName ) 288cdf0e10cSrcweir throw(beans::UnknownPropertyException, uno::RuntimeException) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir ScUnoGuard aGuard; 291cdf0e10cSrcweir 292cdf0e10cSrcweir if ( !pDocShell ) 293cdf0e10cSrcweir throw uno::RuntimeException(); 294cdf0e10cSrcweir 295cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = aPropertyMap.getByName( aPropertyName ); 296cdf0e10cSrcweir if ( !pEntry ) 297cdf0e10cSrcweir throw beans::UnknownPropertyException(); 298cdf0e10cSrcweir 299cdf0e10cSrcweir beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE; 300cdf0e10cSrcweir 301cdf0e10cSrcweir sal_uInt16 nWID = pEntry->nWID; 302cdf0e10cSrcweir if ( nWID == ATTR_FONT || nWID == ATTR_CJK_FONT || nWID == ATTR_CTL_FONT || !nWID ) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir // static default for font is system-dependent, 305cdf0e10cSrcweir // so font default is always treated as "direct value". 306cdf0e10cSrcweir 307cdf0e10cSrcweir eRet = beans::PropertyState_DIRECT_VALUE; 308cdf0e10cSrcweir } 309cdf0e10cSrcweir else 310cdf0e10cSrcweir { 311cdf0e10cSrcweir // check if pool default is set 312cdf0e10cSrcweir 313cdf0e10cSrcweir ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool(); 314cdf0e10cSrcweir if ( pPool->GetPoolDefaultItem( nWID ) != NULL ) 315cdf0e10cSrcweir eRet = beans::PropertyState_DIRECT_VALUE; 316cdf0e10cSrcweir } 317cdf0e10cSrcweir 318cdf0e10cSrcweir return eRet; 319cdf0e10cSrcweir } 320cdf0e10cSrcweir 321cdf0e10cSrcweir uno::Sequence<beans::PropertyState> SAL_CALL ScDocDefaultsObj::getPropertyStates( 322cdf0e10cSrcweir const uno::Sequence<rtl::OUString>& aPropertyNames ) 323cdf0e10cSrcweir throw(beans::UnknownPropertyException, uno::RuntimeException) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir // the simple way: call getPropertyState 326cdf0e10cSrcweir 327cdf0e10cSrcweir ScUnoGuard aGuard; 328cdf0e10cSrcweir const rtl::OUString* pNames = aPropertyNames.getConstArray(); 329cdf0e10cSrcweir uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength()); 330cdf0e10cSrcweir beans::PropertyState* pStates = aRet.getArray(); 331cdf0e10cSrcweir for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++) 332cdf0e10cSrcweir pStates[i] = getPropertyState(pNames[i]); 333cdf0e10cSrcweir return aRet; 334cdf0e10cSrcweir } 335cdf0e10cSrcweir 336cdf0e10cSrcweir void SAL_CALL ScDocDefaultsObj::setPropertyToDefault( const rtl::OUString& aPropertyName ) 337cdf0e10cSrcweir throw(beans::UnknownPropertyException, uno::RuntimeException) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir ScUnoGuard aGuard; 340cdf0e10cSrcweir 341cdf0e10cSrcweir if ( !pDocShell ) 342cdf0e10cSrcweir throw uno::RuntimeException(); 343cdf0e10cSrcweir 344cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = aPropertyMap.getByName( aPropertyName ); 345cdf0e10cSrcweir if ( !pEntry ) 346cdf0e10cSrcweir throw beans::UnknownPropertyException(); 347cdf0e10cSrcweir 348cdf0e10cSrcweir if (pEntry->nWID) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool(); 351cdf0e10cSrcweir pPool->ResetPoolDefaultItem( pEntry->nWID ); 352cdf0e10cSrcweir 353cdf0e10cSrcweir ItemsChanged(); 354cdf0e10cSrcweir } 355cdf0e10cSrcweir } 356cdf0e10cSrcweir 357cdf0e10cSrcweir uno::Any SAL_CALL ScDocDefaultsObj::getPropertyDefault( const rtl::OUString& aPropertyName ) 358cdf0e10cSrcweir throw(beans::UnknownPropertyException, lang::WrappedTargetException, 359cdf0e10cSrcweir uno::RuntimeException) 360cdf0e10cSrcweir { 361cdf0e10cSrcweir // always use static default 362cdf0e10cSrcweir 363cdf0e10cSrcweir ScUnoGuard aGuard; 364cdf0e10cSrcweir 365cdf0e10cSrcweir if ( !pDocShell ) 366cdf0e10cSrcweir throw uno::RuntimeException(); 367cdf0e10cSrcweir 368cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = aPropertyMap.getByName( aPropertyName ); 369cdf0e10cSrcweir if ( !pEntry ) 370cdf0e10cSrcweir throw beans::UnknownPropertyException(); 371cdf0e10cSrcweir 372cdf0e10cSrcweir uno::Any aRet; 373cdf0e10cSrcweir if (pEntry->nWID) 374cdf0e10cSrcweir { 375cdf0e10cSrcweir ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool(); 376cdf0e10cSrcweir const SfxPoolItem* pItem = pPool->GetItem2( pEntry->nWID, SFX_ITEMS_DEFAULT ); 377cdf0e10cSrcweir if (pItem) 378cdf0e10cSrcweir pItem->QueryValue( aRet, pEntry->nMemberId ); 379cdf0e10cSrcweir } 380cdf0e10cSrcweir return aRet; 381cdf0e10cSrcweir } 382cdf0e10cSrcweir 383cdf0e10cSrcweir 384