Return-Path: X-Original-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0150A9CA3 for ; Wed, 20 Jun 2012 09:17:59 +0000 (UTC) Received: (qmail 45649 invoked by uid 500); 20 Jun 2012 09:17:58 -0000 Delivered-To: apmail-incubator-ooo-commits-archive@incubator.apache.org Received: (qmail 45609 invoked by uid 500); 20 Jun 2012 09:17:57 -0000 Mailing-List: contact ooo-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ooo-dev@incubator.apache.org Delivered-To: mailing list ooo-commits@incubator.apache.org Received: (qmail 45584 invoked by uid 99); 20 Jun 2012 09:17:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jun 2012 09:17:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jun 2012 09:17:54 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 39BFD23889E7; Wed, 20 Jun 2012 09:17:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1352002 - in /incubator/ooo/trunk/main: svl/source/items/style.cxx svx/inc/svx/svdundo.hxx svx/source/svdraw/svdundo.cxx Date: Wed, 20 Jun 2012 09:17:24 -0000 To: ooo-commits@incubator.apache.org From: alg@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120620091724.39BFD23889E7@eris.apache.org> Author: alg Date: Wed Jun 20 09:17:23 2012 New Revision: 1352002 URL: http://svn.apache.org/viewvc?rev=1352002&view=rev Log: #120015# Let SdrUndoAttrObj remember a reference to the used style to survive removal of the style by UI (which creates no undo actions). Re-add the style when undoing if needed. Modified: incubator/ooo/trunk/main/svl/source/items/style.cxx incubator/ooo/trunk/main/svx/inc/svx/svdundo.hxx incubator/ooo/trunk/main/svx/source/svdraw/svdundo.cxx Modified: incubator/ooo/trunk/main/svl/source/items/style.cxx URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svl/source/items/style.cxx?rev=1352002&r1=1352001&r2=1352002&view=diff ============================================================================== --- incubator/ooo/trunk/main/svl/source/items/style.cxx (original) +++ incubator/ooo/trunk/main/svl/source/items/style.cxx Wed Jun 20 09:17:23 2012 @@ -806,14 +806,19 @@ void SfxStyleSheetBasePool::Remove( SfxS // Alle Styles umsetzen, deren Parent dieser hier ist ChangeParent( p->GetName(), p->GetParent() ); - com::sun::star::uno::Reference< com::sun::star::lang::XComponent > xComp( static_cast< ::cppu::OWeakObject* >((*aIter).get()), com::sun::star::uno::UNO_QUERY ); - if( xComp.is() ) try - { - xComp->dispose(); - } - catch( com::sun::star::uno::Exception& ) - { - } + // #120015# Do not dispose, the removed StyleSheet may still be used in + // existing SdrUndoAttrObj incarnations. Rely on refcounting for disposal, + // this works well under normal conditions (checked breaking and counting + // on SfxStyleSheetBase constructors and destructors) + // + // com::sun::star::uno::Reference< com::sun::star::lang::XComponent > xComp( static_cast< ::cppu::OWeakObject* >((*aIter).get()), com::sun::star::uno::UNO_QUERY ); + // if( xComp.is() ) try + // { + // xComp->dispose(); + // } + // catch( com::sun::star::uno::Exception& ) + // { + // } aStyles.erase(aIter); Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_ERASED, *p ) ); Modified: incubator/ooo/trunk/main/svx/inc/svx/svdundo.hxx URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/inc/svx/svdundo.hxx?rev=1352002&r1=1352001&r2=1352002&view=diff ============================================================================== --- incubator/ooo/trunk/main/svx/inc/svx/svdundo.hxx (original) +++ incubator/ooo/trunk/main/svx/inc/svx/svdundo.hxx Wed Jun 20 09:17:23 2012 @@ -33,6 +33,7 @@ #include // fuer enum RepeatFuncts #include #include "svx/svxdllapi.h" +#include //************************************************************ // Vorausdeklarationen @@ -166,9 +167,8 @@ protected: SfxItemSet* pRepeatSet; // oder besser den StyleSheetNamen merken? - SfxStyleSheet* pUndoStyleSheet; - SfxStyleSheet* pRedoStyleSheet; - SfxStyleSheet* pRepeatStyleSheet; + rtl::Reference< SfxStyleSheetBase > mxUndoStyleSheet; + rtl::Reference< SfxStyleSheetBase > mxRedoStyleSheet; FASTBOOL bStyleSheet; FASTBOOL bHaveToTakeRedoSet; @@ -181,6 +181,9 @@ protected: // Wenn sich um ein Gruppenobjekt handelt: SdrUndoGroup* pUndoGroup; + // helper to ensure StyleSheet is in pool (provided by SdrModel from SdrObject) + void ensureStyleSheetInStyleSheetPool(SfxStyleSheetBasePool& rStyleSheetPool, SfxStyleSheet& rSheet); + public: SdrUndoAttrObj(SdrObject& rNewObj, FASTBOOL bStyleSheet1=sal_False, FASTBOOL bSaveText=sal_False); virtual ~SdrUndoAttrObj(); Modified: incubator/ooo/trunk/main/svx/source/svdraw/svdundo.cxx URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/svdraw/svdundo.cxx?rev=1352002&r1=1352001&r2=1352002&view=diff ============================================================================== --- incubator/ooo/trunk/main/svx/source/svdraw/svdundo.cxx (original) +++ incubator/ooo/trunk/main/svx/source/svdraw/svdundo.cxx Wed Jun 20 09:17:23 2012 @@ -290,14 +290,29 @@ void SdrUndoObj::ImpShowPageOfThisObject //////////////////////////////////////////////////////////////////////////////////////////////////// +void SdrUndoAttrObj::ensureStyleSheetInStyleSheetPool(SfxStyleSheetBasePool& rStyleSheetPool, SfxStyleSheet& rSheet) +{ + SfxStyleSheetBase* pThere = rStyleSheetPool.Find(rSheet.GetName(), rSheet.GetFamily()); + + if(!pThere) + { + // re-insert remembered style which was removed in the meantime. To do this + // without assertion, do it without parent and set parent after insertion + const UniString aParent(rSheet.GetParent()); + + rSheet.SetParent(UniString()); + rStyleSheetPool.Insert(&rSheet); + rSheet.SetParent(aParent); + } +} + SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, FASTBOOL bStyleSheet1, FASTBOOL bSaveText) : SdrUndoObj(rNewObj), pUndoSet(NULL), pRedoSet(NULL), pRepeatSet(NULL), - pUndoStyleSheet(NULL), - pRedoStyleSheet(NULL), - pRepeatStyleSheet(NULL), + mxUndoStyleSheet(), + mxRedoStyleSheet(), bHaveToTakeRedoSet(sal_True), pTextUndo(NULL), @@ -335,7 +350,7 @@ SdrUndoAttrObj::SdrUndoAttrObj(SdrObject pUndoSet = new SfxItemSet(pObj->GetMergedItemSet()); if(bStyleSheet) - pUndoStyleSheet = pObj->GetStyleSheet(); + mxUndoStyleSheet = pObj->GetStyleSheet(); if(bSaveText) { @@ -394,7 +409,7 @@ void SdrUndoAttrObj::Undo() pRedoSet = new SfxItemSet(pObj->GetMergedItemSet()); if(bStyleSheet) - pRedoStyleSheet=pObj->GetStyleSheet(); + mxRedoStyleSheet = pObj->GetStyleSheet(); if(pTextUndo) { @@ -408,8 +423,18 @@ void SdrUndoAttrObj::Undo() if(bStyleSheet) { - pRedoStyleSheet = pObj->GetStyleSheet(); - pObj->SetStyleSheet(pUndoStyleSheet, sal_True); + mxRedoStyleSheet = pObj->GetStyleSheet(); + SfxStyleSheet* pSheet = dynamic_cast< SfxStyleSheet* >(mxUndoStyleSheet.get()); + + if(pSheet && pObj->GetModel() && pObj->GetModel()->GetStyleSheetPool()) + { + ensureStyleSheetInStyleSheetPool(*pObj->GetModel()->GetStyleSheetPool(), *pSheet); + pObj->SetStyleSheet(pSheet, sal_True); + } + else + { + OSL_ENSURE(false, "OOps, something went wrong in SdrUndoAttrObj (!)"); + } } sdr::properties::ItemChangeBroadcaster aItemChange(*pObj); @@ -482,8 +507,18 @@ void SdrUndoAttrObj::Redo() { if(bStyleSheet) { - pUndoStyleSheet = pObj->GetStyleSheet(); - pObj->SetStyleSheet(pRedoStyleSheet, sal_True); + mxUndoStyleSheet = pObj->GetStyleSheet(); + SfxStyleSheet* pSheet = dynamic_cast< SfxStyleSheet* >(mxRedoStyleSheet.get()); + + if(pSheet && pObj->GetModel() && pObj->GetModel()->GetStyleSheetPool()) + { + ensureStyleSheetInStyleSheetPool(*pObj->GetModel()->GetStyleSheetPool(), *pSheet); + pObj->SetStyleSheet(pSheet, sal_True); + } + else + { + OSL_ENSURE(false, "OOps, something went wrong in SdrUndoAttrObj (!)"); + } } sdr::properties::ItemChangeBroadcaster aItemChange(*pObj);