diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-01-11 10:26:41 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-01-11 11:08:02 +0100 |
commit | 0e4b36269097f8865bdbc1b9d299a2776ae0cc06 (patch) | |
tree | e5446ab0d7a42b98ed9333c25ac66ba54c438f53 /sc | |
parent | 5c4d1b05faa8a3d704fc74a186a173f8cc019cc1 (diff) |
ScGlobal::GetAutoFormat not always required to create fresh instance.
...at least in ~ScAutoFormatObj it appears unnecessary and can lead to
crashes during Desktop::DeregisterServices (when ScGlobal::ppRscString
is already null and ScAutoFormat ctor calls ScGlobal::GetRscString).
Therefore split GetAutoFormat in two, GetOrCreateAutoFormat for cases
that probably need a non-null return and GetAutoFormat for those that
are OK with a null return.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/global.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/data/global.cxx | 5 | ||||
-rw-r--r-- | sc/source/core/data/table4.cxx | 232 | ||||
-rw-r--r-- | sc/source/ui/docshell/docfunc.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/scuiautofmt.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/unoobj/afmtuno.cxx | 88 | ||||
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh3.cxx | 4 |
8 files changed, 162 insertions, 180 deletions
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index a810400da767..ac10094ab4d1 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -562,6 +562,7 @@ public: SC_DLLPUBLIC static const SvxSearchItem& GetSearchItem(); SC_DLLPUBLIC static void SetSearchItem( const SvxSearchItem& rNew ); SC_DLLPUBLIC static ScAutoFormat* GetAutoFormat(); + SC_DLLPUBLIC static ScAutoFormat* GetOrCreateAutoFormat(); static void ClearAutoFormat(); //BugId 54209 static FuncCollection* GetFuncCollection(); SC_DLLPUBLIC static ScUnoAddInCollection* GetAddInCollection(); diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 6de3782d3982..c43a8534fd0e 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -299,6 +299,11 @@ void ScGlobal::ClearAutoFormat() ScAutoFormat* ScGlobal::GetAutoFormat() { + return pAutoFormat; +} + +ScAutoFormat* ScGlobal::GetOrCreateAutoFormat() +{ if ( !pAutoFormat ) { pAutoFormat = new ScAutoFormat; diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index 9b382140a5b9..bc99c5ca03c3 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -1592,14 +1592,10 @@ void ScTable::Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, void ScTable::AutoFormatArea(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScPatternAttr& rAttr, sal_uInt16 nFormatNo) { - ScAutoFormat* pAutoFormat = ScGlobal::GetAutoFormat(); - if (pAutoFormat) + ScAutoFormatData* pData = (*ScGlobal::GetOrCreateAutoFormat())[nFormatNo]; + if (pData) { - ScAutoFormatData* pData = (*pAutoFormat)[nFormatNo]; - if (pData) - { - ApplyPatternArea(nStartCol, nStartRow, nEndCol, nEndRow, rAttr); - } + ApplyPatternArea(nStartCol, nStartRow, nEndCol, nEndRow, rAttr); } } @@ -1608,140 +1604,136 @@ void ScTable::AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW { if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow)) { - ScAutoFormat* pAutoFormat = ScGlobal::GetAutoFormat(); - if (pAutoFormat) + ScAutoFormatData* pData = (*ScGlobal::GetOrCreateAutoFormat())[nFormatNo]; + if (pData) { - ScAutoFormatData* pData = (*pAutoFormat)[nFormatNo]; - if (pData) + ScPatternAttr* pPatternAttrs[16]; + for (sal_uInt8 i = 0; i < 16; ++i) + { + pPatternAttrs[i] = new ScPatternAttr(pDocument->GetPool()); + pData->FillToItemSet(i, pPatternAttrs[i]->GetItemSet(), *pDocument); + } + + SCCOL nCol = nStartCol; + SCROW nRow = nStartRow; + sal_uInt16 nIndex = 0; + // Linke obere Ecke + AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo); + // Linke Spalte + if (pData->IsEqualData(4, 8)) + AutoFormatArea(nStartCol, nStartRow + 1, nStartCol, nEndRow - 1, *pPatternAttrs[4], nFormatNo); + else { - ScPatternAttr* pPatternAttrs[16]; - for (sal_uInt8 i = 0; i < 16; ++i) + nIndex = 4; + for (nRow = nStartRow + 1; nRow < nEndRow; nRow++) { - pPatternAttrs[i] = new ScPatternAttr(pDocument->GetPool()); - pData->FillToItemSet(i, pPatternAttrs[i]->GetItemSet(), *pDocument); + AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo); + if (nIndex == 4) + nIndex = 8; + else + nIndex = 4; } - - SCCOL nCol = nStartCol; - SCROW nRow = nStartRow; - sal_uInt16 nIndex = 0; - // Linke obere Ecke - AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo); - // Linke Spalte - if (pData->IsEqualData(4, 8)) - AutoFormatArea(nStartCol, nStartRow + 1, nStartCol, nEndRow - 1, *pPatternAttrs[4], nFormatNo); - else + } + // Linke untere Ecke + nRow = nEndRow; + nIndex = 12; + AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo); + // Rechte obere Ecke + nCol = nEndCol; + nRow = nStartRow; + nIndex = 3; + AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo); + // Rechte Spalte + if (pData->IsEqualData(7, 11)) + AutoFormatArea(nEndCol, nStartRow + 1, nEndCol, nEndRow - 1, *pPatternAttrs[7], nFormatNo); + else + { + nIndex = 7; + for (nRow = nStartRow + 1; nRow < nEndRow; nRow++) { - nIndex = 4; - for (nRow = nStartRow + 1; nRow < nEndRow; nRow++) - { - AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo); - if (nIndex == 4) - nIndex = 8; - else - nIndex = 4; - } + AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo); + if (nIndex == 7) + nIndex = 11; + else + nIndex = 7; } - // Linke untere Ecke - nRow = nEndRow; - nIndex = 12; + } + // Rechte untere Ecke + nRow = nEndRow; + nIndex = 15; + AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo); + nRow = nStartRow; + nIndex = 1; + for (nCol = nStartCol + 1; nCol < nEndCol; nCol++) + { AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo); - // Rechte obere Ecke - nCol = nEndCol; - nRow = nStartRow; - nIndex = 3; + if (nIndex == 1) + nIndex = 2; + else + nIndex = 1; + } + // Untere Zeile + nRow = nEndRow; + nIndex = 13; + for (nCol = nStartCol + 1; nCol < nEndCol; nCol++) + { AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo); - // Rechte Spalte - if (pData->IsEqualData(7, 11)) - AutoFormatArea(nEndCol, nStartRow + 1, nEndCol, nEndRow - 1, *pPatternAttrs[7], nFormatNo); + if (nIndex == 13) + nIndex = 14; else + nIndex = 13; + } + // Boddy + if ((pData->IsEqualData(5, 6)) && (pData->IsEqualData(9, 10)) && (pData->IsEqualData(5, 9))) + AutoFormatArea(nStartCol + 1, nStartRow + 1, nEndCol-1, nEndRow - 1, *pPatternAttrs[5], nFormatNo); + else + { + if ((pData->IsEqualData(5, 9)) && (pData->IsEqualData(6, 10))) { - nIndex = 7; - for (nRow = nStartRow + 1; nRow < nEndRow; nRow++) + nIndex = 5; + for (nCol = nStartCol + 1; nCol < nEndCol; nCol++) { - AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo); - if (nIndex == 7) - nIndex = 11; + AutoFormatArea(nCol, nStartRow + 1, nCol, nEndRow - 1, *pPatternAttrs[nIndex], nFormatNo); + if (nIndex == 5) + nIndex = 6; else - nIndex = 7; + nIndex = 5; } } - // Rechte untere Ecke - nRow = nEndRow; - nIndex = 15; - AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo); - nRow = nStartRow; - nIndex = 1; - for (nCol = nStartCol + 1; nCol < nEndCol; nCol++) - { - AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo); - if (nIndex == 1) - nIndex = 2; - else - nIndex = 1; - } - // Untere Zeile - nRow = nEndRow; - nIndex = 13; - for (nCol = nStartCol + 1; nCol < nEndCol; nCol++) - { - AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo); - if (nIndex == 13) - nIndex = 14; - else - nIndex = 13; - } - // Boddy - if ((pData->IsEqualData(5, 6)) && (pData->IsEqualData(9, 10)) && (pData->IsEqualData(5, 9))) - AutoFormatArea(nStartCol + 1, nStartRow + 1, nEndCol-1, nEndRow - 1, *pPatternAttrs[5], nFormatNo); else { - if ((pData->IsEqualData(5, 9)) && (pData->IsEqualData(6, 10))) + nIndex = 5; + for (nCol = nStartCol + 1; nCol < nEndCol; nCol++) { - nIndex = 5; - for (nCol = nStartCol + 1; nCol < nEndCol; nCol++) + for (nRow = nStartRow + 1; nRow < nEndRow; nRow++) { - AutoFormatArea(nCol, nStartRow + 1, nCol, nEndRow - 1, *pPatternAttrs[nIndex], nFormatNo); - if (nIndex == 5) - nIndex = 6; - else - nIndex = 5; - } - } - else - { - nIndex = 5; - for (nCol = nStartCol + 1; nCol < nEndCol; nCol++) - { - for (nRow = nStartRow + 1; nRow < nEndRow; nRow++) + AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo); + if ((nIndex == 5) || (nIndex == 9)) { - AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo); - if ((nIndex == 5) || (nIndex == 9)) - { - if (nIndex == 5) - nIndex = 9; - else - nIndex = 5; - } + if (nIndex == 5) + nIndex = 9; else - { - if (nIndex == 6) - nIndex = 10; - else - nIndex = 6; - } - } // for nRow - if ((nIndex == 5) || (nIndex == 9)) - nIndex = 6; + nIndex = 5; + } else - nIndex = 5; - } // for nCol - } // if not equal Column - } // if not all equal - - for (sal_uInt8 j = 0; j < 16; ++j) - delete pPatternAttrs[j]; - } // if AutoFormatData != NULL - } // if AutoFormat != NULL + { + if (nIndex == 6) + nIndex = 10; + else + nIndex = 6; + } + } // for nRow + if ((nIndex == 5) || (nIndex == 9)) + nIndex = 6; + else + nIndex = 5; + } // for nCol + } // if not equal Column + } // if not all equal + + for (sal_uInt8 j = 0; j < 16; ++j) + delete pPatternAttrs[j]; + } // if AutoFormatData != NULL } // if ValidColRow } diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index dd3df9559c96..8ed622667ad4 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -3693,9 +3693,9 @@ sal_Bool ScDocFunc::AutoFormat( const ScRange& rRange, const ScMarkData* pTabMar aMark.SelectTable( nTab, sal_True ); } - ScAutoFormat* pAutoFormat = ScGlobal::GetAutoFormat(); + ScAutoFormat* pAutoFormat = ScGlobal::GetOrCreateAutoFormat(); ScEditableTester aTester( pDoc, nStartCol,nStartRow, nEndCol,nEndRow, aMark ); - if ( pAutoFormat && nFormatNo < pAutoFormat->GetCount() && aTester.IsEditable() ) + if ( nFormatNo < pAutoFormat->GetCount() && aTester.IsEditable() ) { WaitObject aWait( rDocShell.GetActiveDialogParent() ); diff --git a/sc/source/ui/miscdlgs/scuiautofmt.cxx b/sc/source/ui/miscdlgs/scuiautofmt.cxx index d51b420163ab..9466a4b53b81 100644 --- a/sc/source/ui/miscdlgs/scuiautofmt.cxx +++ b/sc/source/ui/miscdlgs/scuiautofmt.cxx @@ -194,7 +194,7 @@ IMPL_LINK( ScAutoFormatDlg, CloseHdl, PushButton *, pBtn ) if ( pBtn == &aBtnOk || pBtn == &aBtnCancel ) { if ( bCoreDataChanged ) - ScGlobal::GetAutoFormat()->Save(); + ScGlobal::GetOrCreateAutoFormat()->Save(); EndDialog( (pBtn == &aBtnOk) ? RET_OK : RET_CANCEL ); } @@ -206,7 +206,7 @@ IMPL_LINK( ScAutoFormatDlg, CloseHdl, PushButton *, pBtn ) IMPL_LINK_INLINE_START( ScAutoFormatDlg, DblClkHdl, void *, EMPTYARG ) { if ( bCoreDataChanged ) - ScGlobal::GetAutoFormat()->Save(); + ScGlobal::GetOrCreateAutoFormat()->Save(); EndDialog( RET_OK ); return 0; diff --git a/sc/source/ui/unoobj/afmtuno.cxx b/sc/source/ui/unoobj/afmtuno.cxx index f9dc03db6f8c..58abbe449302 100644 --- a/sc/source/ui/unoobj/afmtuno.cxx +++ b/sc/source/ui/unoobj/afmtuno.cxx @@ -221,8 +221,7 @@ uno::Sequence<rtl::OUString> ScAutoFormatsObj::getSupportedServiceNames_Static() ScAutoFormatObj* ScAutoFormatsObj::GetObjectByIndex_Impl(sal_uInt16 nIndex) { - ScAutoFormat* pFormats = ScGlobal::GetAutoFormat(); - if (pFormats && nIndex < pFormats->GetCount()) + if (nIndex < ScGlobal::GetOrCreateAutoFormat()->GetCount()) return new ScAutoFormatObj(nIndex); return NULL; // falscher Index @@ -230,14 +229,11 @@ ScAutoFormatObj* ScAutoFormatsObj::GetObjectByIndex_Impl(sal_uInt16 nIndex) ScAutoFormatObj* ScAutoFormatsObj::GetObjectByName_Impl(const rtl::OUString& aName) { - ScAutoFormat* pFormats = ScGlobal::GetAutoFormat(); - if (pFormats) - { - String aString(aName); - sal_uInt16 nIndex; - if (lcl_FindAutoFormatIndex( *pFormats, aString, nIndex )) - return GetObjectByIndex_Impl(nIndex); - } + String aString(aName); + sal_uInt16 nIndex; + if (lcl_FindAutoFormatIndex( + *ScGlobal::GetOrCreateAutoFormat(), aString, nIndex )) + return GetObjectByIndex_Impl(nIndex); return NULL; } @@ -257,10 +253,10 @@ void SAL_CALL ScAutoFormatsObj::insertByName( const rtl::OUString& aName, const if ( pFormatObj && !pFormatObj->IsInserted() ) // noch nicht eingefuegt? { String aNameStr(aName); - ScAutoFormat* pFormats = ScGlobal::GetAutoFormat(); + ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat(); sal_uInt16 nDummy; - if (pFormats && !lcl_FindAutoFormatIndex( *pFormats, aNameStr, nDummy )) + if (!lcl_FindAutoFormatIndex( *pFormats, aNameStr, nDummy )) { ScAutoFormatData* pNew = new ScAutoFormatData(); pNew->SetName( aNameStr ); @@ -314,10 +310,10 @@ void SAL_CALL ScAutoFormatsObj::removeByName( const rtl::OUString& aName ) { SolarMutexGuard aGuard; String aNameStr(aName); - ScAutoFormat* pFormats = ScGlobal::GetAutoFormat(); + ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat(); sal_uInt16 nIndex; - if (pFormats && lcl_FindAutoFormatIndex( *pFormats, aNameStr, nIndex )) + if (lcl_FindAutoFormatIndex( *pFormats, aNameStr, nIndex )) { pFormats->AtFree( nIndex ); @@ -344,11 +340,7 @@ uno::Reference<container::XEnumeration> SAL_CALL ScAutoFormatsObj::createEnumera sal_Int32 SAL_CALL ScAutoFormatsObj::getCount() throw(uno::RuntimeException) { SolarMutexGuard aGuard; - ScAutoFormat* pFormats = ScGlobal::GetAutoFormat(); - if (pFormats) - return pFormats->GetCount(); - - return 0; + return ScGlobal::GetOrCreateAutoFormat()->GetCount(); } uno::Any SAL_CALL ScAutoFormatsObj::getByIndex( sal_Int32 nIndex ) @@ -391,35 +383,27 @@ uno::Sequence<rtl::OUString> SAL_CALL ScAutoFormatsObj::getElementNames() throw(uno::RuntimeException) { SolarMutexGuard aGuard; - ScAutoFormat* pFormats = ScGlobal::GetAutoFormat(); - if (pFormats) + ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat(); + String aName; + sal_uInt16 nCount = pFormats->GetCount(); + uno::Sequence<rtl::OUString> aSeq(nCount); + rtl::OUString* pAry = aSeq.getArray(); + for (sal_uInt16 i=0; i<nCount; i++) { - String aName; - sal_uInt16 nCount = pFormats->GetCount(); - uno::Sequence<rtl::OUString> aSeq(nCount); - rtl::OUString* pAry = aSeq.getArray(); - for (sal_uInt16 i=0; i<nCount; i++) - { - (*pFormats)[i]->GetName(aName); - pAry[i] = aName; - } - return aSeq; + (*pFormats)[i]->GetName(aName); + pAry[i] = aName; } - return uno::Sequence<rtl::OUString>(0); + return aSeq; } sal_Bool SAL_CALL ScAutoFormatsObj::hasByName( const rtl::OUString& aName ) throw(uno::RuntimeException) { SolarMutexGuard aGuard; - ScAutoFormat* pFormats = ScGlobal::GetAutoFormat(); - if (pFormats) - { - String aString(aName); - sal_uInt16 nDummy; - return lcl_FindAutoFormatIndex( *pFormats, aString, nDummy ); - } - return false; + String aString(aName); + sal_uInt16 nDummy; + return lcl_FindAutoFormatIndex( + *ScGlobal::GetOrCreateAutoFormat(), aString, nDummy ); } //------------------------------------------------------------------------ @@ -553,8 +537,8 @@ sal_Bool SAL_CALL ScAutoFormatObj::hasElements() throw(uno::RuntimeException) rtl::OUString SAL_CALL ScAutoFormatObj::getName() throw(uno::RuntimeException) { SolarMutexGuard aGuard; - ScAutoFormat* pFormats = ScGlobal::GetAutoFormat(); - if (pFormats && IsInserted() && nFormatIndex < pFormats->GetCount()) + ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat(); + if (IsInserted() && nFormatIndex < pFormats->GetCount()) { String aName; (*pFormats)[nFormatIndex]->GetName(aName); @@ -568,10 +552,10 @@ void SAL_CALL ScAutoFormatObj::setName( const rtl::OUString& aNewName ) { SolarMutexGuard aGuard; String aNewString(aNewName); - ScAutoFormat* pFormats = ScGlobal::GetAutoFormat(); + ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat(); sal_uInt16 nDummy; - if (pFormats && IsInserted() && nFormatIndex < pFormats->GetCount() && + if (IsInserted() && nFormatIndex < pFormats->GetCount() && !lcl_FindAutoFormatIndex( *pFormats, aNewString, nDummy )) { ScAutoFormatData* pData = (*pFormats)[nFormatIndex]; @@ -619,8 +603,8 @@ void SAL_CALL ScAutoFormatObj::setPropertyValue( uno::RuntimeException) { SolarMutexGuard aGuard; - ScAutoFormat* pFormats = ScGlobal::GetAutoFormat(); - if (pFormats && IsInserted() && nFormatIndex < pFormats->GetCount()) + ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat(); + if (IsInserted() && nFormatIndex < pFormats->GetCount()) { ScAutoFormatData* pData = (*pFormats)[nFormatIndex]; OSL_ENSURE(pData,"AutoFormat Daten nicht da"); @@ -654,8 +638,8 @@ uno::Any SAL_CALL ScAutoFormatObj::getPropertyValue( const rtl::OUString& aPrope SolarMutexGuard aGuard; uno::Any aAny; - ScAutoFormat* pFormats = ScGlobal::GetAutoFormat(); - if (pFormats && IsInserted() && nFormatIndex < pFormats->GetCount()) + ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat(); + if (IsInserted() && nFormatIndex < pFormats->GetCount()) { ScAutoFormatData* pData = (*pFormats)[nFormatIndex]; OSL_ENSURE(pData,"AutoFormat Daten nicht da"); @@ -724,11 +708,11 @@ void SAL_CALL ScAutoFormatFieldObj::setPropertyValue( uno::RuntimeException) { SolarMutexGuard aGuard; - ScAutoFormat* pFormats = ScGlobal::GetAutoFormat(); + ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat(); const SfxItemPropertySimpleEntry* pEntry = aPropSet.getPropertyMap().getByName( aPropertyName ); - if ( pEntry && pEntry->nWID && pFormats && nFormatIndex < pFormats->GetCount() ) + if ( pEntry && pEntry->nWID && nFormatIndex < pFormats->GetCount() ) { ScAutoFormatData* pData = (*pFormats)[nFormatIndex]; @@ -814,11 +798,11 @@ uno::Any SAL_CALL ScAutoFormatFieldObj::getPropertyValue( const rtl::OUString& a SolarMutexGuard aGuard; uno::Any aVal; - ScAutoFormat* pFormats = ScGlobal::GetAutoFormat(); + ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat(); const SfxItemPropertySimpleEntry* pEntry = aPropSet.getPropertyMap().getByName( aPropertyName ); - if ( pEntry && pEntry->nWID && pFormats && nFormatIndex < pFormats->GetCount() ) + if ( pEntry && pEntry->nWID && nFormatIndex < pFormats->GetCount() ) { const ScAutoFormatData* pData = (*pFormats)[nFormatIndex]; diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index c93f67589d89..2d3db0a7ed5f 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -5500,10 +5500,10 @@ void SAL_CALL ScCellRangeObj::autoFormat( const rtl::OUString& aName ) throw(lang::IllegalArgumentException, uno::RuntimeException) { SolarMutexGuard aGuard; - ScAutoFormat* pAutoFormat = ScGlobal::GetAutoFormat(); ScDocShell* pDocSh = GetDocShell(); - if ( pDocSh && pAutoFormat ) + if ( pDocSh ) { + ScAutoFormat* pAutoFormat = ScGlobal::GetOrCreateAutoFormat(); String aNameString(aName); sal_uInt16 nCount = pAutoFormat->GetCount(); sal_uInt16 nIndex; diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index 19111c81a672..a9950c8213ca 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -816,7 +816,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) if ( pReqArgs ) { const SfxStringItem& rNameItem = (const SfxStringItem&)pReqArgs->Get( SID_AUTOFORMAT ); - ScAutoFormat* pFormat = ScGlobal::GetAutoFormat(); + ScAutoFormat* pFormat = ScGlobal::GetOrCreateAutoFormat(); sal_uInt16 nIndex = pFormat->FindIndexPerName( rNameItem.GetValue() ); pTabViewShell->AutoFormat( nIndex ); @@ -831,7 +831,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "ScAbstractFactory create fail!"); - AbstractScAutoFormatDlg* pDlg = pFact->CreateScAutoFormatDlg( pDlgParent, ScGlobal::GetAutoFormat(), pNewEntry,GetViewData()->GetDocument(), RID_SCDLG_AUTOFORMAT ); + AbstractScAutoFormatDlg* pDlg = pFact->CreateScAutoFormatDlg( pDlgParent, ScGlobal::GetOrCreateAutoFormat(), pNewEntry,GetViewData()->GetDocument(), RID_SCDLG_AUTOFORMAT ); OSL_ENSURE(pDlg, "Dialog create fail!"); if ( pDlg->Execute() == RET_OK ) |