summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Nebel <nn@openoffice.org>2010-06-23 12:03:27 +0200
committerNiklas Nebel <nn@openoffice.org>2010-06-23 12:03:27 +0200
commitc5af83ae71ae9f2600e16330d6a7df21451ec2a5 (patch)
tree89fb30d021e3b75c6e901c19b3b4b8a8cbcdd466
parente3067d7a280a6f75ce3cc550f3159eb8bb19ba94 (diff)
unoawt2: #i112622# convert cell style names to pointers after creating a style
-rw-r--r--sc/inc/docpool.hxx1
-rw-r--r--sc/source/core/data/docpool.cxx20
-rw-r--r--sc/source/ui/undo/undostyl.cxx4
-rw-r--r--sc/source/ui/unoobj/styleuno.cxx8
-rw-r--r--sc/source/ui/view/formatsh.cxx4
5 files changed, 37 insertions, 0 deletions
diff --git a/sc/inc/docpool.hxx b/sc/inc/docpool.hxx
index cc1df1f86..353dd4044 100644
--- a/sc/inc/docpool.hxx
+++ b/sc/inc/docpool.hxx
@@ -65,6 +65,7 @@ public:
static void CheckRef( const SfxPoolItem& );
void StyleDeleted( ScStyleSheet* pStyle ); // Loeschen von Vorlagen im Organizer
+ void CellStyleCreated( const String& rName );
virtual SfxItemPresentation GetPresentation(
const SfxPoolItem& rItem,
SfxItemPresentation ePresentation,
diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx
index 4589e7928..b9078a530 100644
--- a/sc/source/core/data/docpool.cxx
+++ b/sc/source/core/data/docpool.cxx
@@ -651,6 +651,26 @@ void ScDocumentPool::StyleDeleted( ScStyleSheet* pStyle )
}
}
+void ScDocumentPool::CellStyleCreated( const String& rName )
+{
+ // If a style was created, don't keep any pattern with its name string in the pool,
+ // because it would compare equal to a pattern with a pointer to the new style.
+ // Calling StyleSheetChanged isn't enough because the pool may still contain items
+ // for undo or clipboard content.
+
+ sal_uInt16 nCount = GetItemCount(ATTR_PATTERN);
+ for (sal_uInt16 i=0; i<nCount; i++)
+ {
+ ScPatternAttr* pPattern = (ScPatternAttr*)GetItem(ATTR_PATTERN, i);
+ if ( pPattern && pPattern->GetStyleSheet() == NULL )
+ {
+ const String* pStyleName = pPattern->GetStyleName();
+ if ( pStyleName && *pStyleName == rName )
+ pPattern->UpdateStyleSheet(); // find and store style pointer
+ }
+ }
+}
+
SfxItemPool* __EXPORT ScDocumentPool::Clone() const
{
return new SfxItemPool (*this, TRUE);
diff --git a/sc/source/ui/undo/undostyl.cxx b/sc/source/ui/undo/undostyl.cxx
index d807dfec4..7f85a38ad 100644
--- a/sc/source/ui/undo/undostyl.cxx
+++ b/sc/source/ui/undo/undostyl.cxx
@@ -37,6 +37,7 @@
#include "undostyl.hxx"
#include "docsh.hxx"
+#include "docpool.hxx"
#include "stlpool.hxx"
#include "printfun.hxx"
#include "scmod.hxx"
@@ -166,6 +167,9 @@ void ScUndoModifyStyle::DoChange( ScDocShell* pDocSh, const String& rName,
{
// create style (with new name)
pStyle = &pStlPool->Make( aNewName, eStyleFamily, SFXSTYLEBIT_USERDEF );
+
+ if ( eStyleFamily == SFX_STYLE_FAMILY_PARA )
+ pDoc->GetPool()->CellStyleCreated( aNewName );
}
if ( pStyle )
diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx
index 3ddccdb5b..e3936b7db 100644
--- a/sc/source/ui/unoobj/styleuno.cxx
+++ b/sc/source/ui/unoobj/styleuno.cxx
@@ -68,6 +68,7 @@
#include "docsh.hxx"
#include "attrib.hxx"
#include "stlpool.hxx"
+#include "docpool.hxx"
#include "unoguard.hxx"
#include "miscuno.hxx"
#include "convuno.hxx"
@@ -830,6 +831,9 @@ void SAL_CALL ScStyleFamilyObj::insertByName( const rtl::OUString& aName, const
{
(void)pStylePool->Make( aNameStr, eFamily, SFXSTYLEBIT_USERDEF );
+ if ( eFamily == SFX_STYLE_FAMILY_PARA && !pDoc->IsImportingXML() )
+ pDoc->GetPool()->CellStyleCreated( aNameStr );
+
pStyleObj->InitDoc( pDocShell, aNameStr ); // Objekt kann benutzt werden
pDocShell->SetDocumentModified(); // verwendet wird der neue Style noch nicht
@@ -1287,6 +1291,10 @@ void SAL_CALL ScStyleObj::setName( const rtl::OUString& aNewName )
{
aStyleName = aString; //! notify other objects for this style?
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if ( eFamily == SFX_STYLE_FAMILY_PARA && !pDoc->IsImportingXML() )
+ pDoc->GetPool()->CellStyleCreated( aString );
+
// Zellvorlagen = 2, Seitenvorlagen = 4
UINT16 nId = ( eFamily == SFX_STYLE_FAMILY_PARA ) ?
SID_STYLE_FAMILY2 : SID_STYLE_FAMILY4;
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 9f6bf0d13..ccf501a36 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -551,6 +551,8 @@ void __EXPORT ScFormatShell::ExecuteStyle( SfxRequest& rReq )
if ( bConvertBack )
// Namen zu Style-Pointer
pDoc->UpdStlShtPtrsFrmNms();
+ else
+ pDoc->GetPool()->CellStyleCreated( aStyleName );
// Attribute uebernehmen und Style anwenden
pStyleSheet->GetItemSet().Put( aAttrSet );
@@ -839,6 +841,8 @@ void __EXPORT ScFormatShell::ExecuteStyle( SfxRequest& rReq )
rNewSet.Put( SvxLanguageItem(
pNew->GetLanguage(), ATTR_LANGUAGE_FORMAT ) );
}
+
+ pDoc->GetPool()->CellStyleCreated( pStyleSheet->GetName() );
}
else
{