[libreoffice/f17] Resolves: rhbz#760765 impress doesn't copy custom styles from one file to another

David Tardon dtardon at fedoraproject.org
Tue Jan 22 13:47:55 UTC 2013


commit 6cc3af7050d63a31664d3a406fe24c80996d2b7f
Author: David Tardon <dtardon at redhat.com>
Date:   Tue Jan 22 14:03:26 2013 +0100

    Resolves: rhbz#760765 impress doesn't copy custom styles from one file to another

 ...z-760765-copy-custom-styles-on-copy-paste.patch |  202 ++++++++++++++++++++
 libreoffice.spec                                   |    8 +-
 2 files changed, 209 insertions(+), 1 deletions(-)
---
diff --git a/0001-rhbz-760765-copy-custom-styles-on-copy-paste.patch b/0001-rhbz-760765-copy-custom-styles-on-copy-paste.patch
new file mode 100644
index 0000000..d7d8122
--- /dev/null
+++ b/0001-rhbz-760765-copy-custom-styles-on-copy-paste.patch
@@ -0,0 +1,202 @@
+From fadd1f36116f3de4fd630b3e0818e987974d3f51 Mon Sep 17 00:00:00 2001
+From: David Tardon <dtardon at redhat.com>
+Date: Thu, 17 Jan 2013 15:01:32 +0100
+Subject: [PATCH] rhbz#760765 copy custom styles on copy & paste
+
+Conflicts:
+	sd/source/core/drawdoc3.cxx
+
+Change-Id: Icaacf3bc1a02a017692432aec36aba06d3f5dde5
+---
+ sd/inc/stlpool.hxx          |  3 +++
+ sd/source/core/drawdoc3.cxx | 49 ++++++++++++++++++++++++++++++++++++++++++---
+ sd/source/core/stlpool.cxx  | 18 +++++++++++++++++
+ sd/source/core/stlsheet.cxx | 16 +++++++++------
+ 4 files changed, 77 insertions(+), 9 deletions(-)
+
+diff --git a/sd/inc/stlpool.hxx b/sd/inc/stlpool.hxx
+index 2a7f82a..76ec285 100644
+--- a/sd/inc/stlpool.hxx
++++ b/sd/inc/stlpool.hxx
+@@ -89,6 +89,8 @@ public:
+     void                CopyGraphicSheets(SdStyleSheetPool& rSourcePool);
+     void                CopyCellSheets(SdStyleSheetPool& rSourcePool);
+     void                CopyTableStyles(SdStyleSheetPool& rSourcePool);
++    void                CopyGraphicSheets(SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets);
++    void                CopyCellSheets(SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets);
+ 
+     void                CreatePseudosIfNecessary();
+     void                UpdateStdNames();
+@@ -130,6 +132,7 @@ public:
+     virtual void SAL_CALL release (void) throw ();
+ protected:
+     void CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily );
++    void CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, SdStyleSheetVector& rCreatedSheets );
+ 
+     virtual SfxStyleSheetBase* Create(const String& rName, SfxStyleFamily eFamily, sal_uInt16 nMask);
+     virtual SfxStyleSheetBase* Create(const SdStyleSheet& rStyle);
+diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
+index c05af48..a7d2dab 100644
+--- a/sd/source/core/drawdoc3.cxx
++++ b/sd/source/core/drawdoc3.cxx
+@@ -405,6 +405,26 @@ private:
+ };
+ 
+ 
++namespace
++{
++
++void
++lcl_removeUnusedStyles(SfxStyleSheetBasePool* const pStyleSheetPool, SdStyleSheetVector& rStyles)
++{
++    SdStyleSheetVector aUsedStyles;
++    aUsedStyles.reserve(rStyles.size());
++    for (SdStyleSheetVector::const_iterator aIt(rStyles.begin()), aLast(rStyles.end()); aIt != aLast; ++aIt)
++    {
++        if ((*aIt)->IsUsed())
++            aUsedStyles.push_back(*aIt);
++        else
++            pStyleSheetPool->Remove((*aIt).get());
++    }
++    rStyles = aUsedStyles;
++}
++
++}
++
+ sal_Bool SdDrawDocument::InsertBookmarkAsPage(
+     List* pBookmarkList,
+     List* pExchangeList,            // Liste der zu verwendenen Namen
+@@ -534,9 +554,9 @@ sal_Bool SdDrawDocument::InsertBookmarkAsPage(
+     /**************************************************************************
+     * Die tatsaechlich benoetigten Vorlagen kopieren
+     **************************************************************************/
+-    SdStyleSheetPool* pBookmarkStyleSheetPool =
+-    (SdStyleSheetPool*) pBookmarkDoc->GetStyleSheetPool();
+     String* pLayout = (String*) pLayoutsToTransfer->First();
++    SdStyleSheetPool* pBookmarkStyleSheetPool = dynamic_cast<SdStyleSheetPool*>(pBookmarkDoc->GetStyleSheetPool());
++    SdStyleSheetPool* pStyleSheetPool = dynamic_cast<SdStyleSheetPool*>(GetStyleSheetPool());
+ 
+     // Wenn Vorlagen kopiert werden muessen, dann muessen auch die
+     // MasterPages kopiert werden!
+@@ -547,7 +567,7 @@ sal_Bool SdDrawDocument::InsertBookmarkAsPage(
+     {
+         SdStyleSheetVector aCreatedStyles;
+ 
+-        ((SdStyleSheetPool*)GetStyleSheetPool())->CopyLayoutSheets(*pLayout, *pBookmarkStyleSheetPool,aCreatedStyles);
++        pStyleSheetPool->CopyLayoutSheets(*pLayout, *pBookmarkStyleSheetPool,aCreatedStyles);
+ 
+         if(!aCreatedStyles.empty())
+         {
+@@ -565,6 +585,18 @@ sal_Bool SdDrawDocument::InsertBookmarkAsPage(
+ 
+     delete pLayoutsToTransfer;
+ 
++    // Copy styles. This unconditionally copies all styles, even those
++    // that are not used in any of the inserted pages. The unused styles
++    // are then removed at the end of the function, where we also create
++    // undo records for the inserted styles.
++    SdStyleSheetVector aNewGraphicStyles;
++    pStyleSheetPool->CopyGraphicSheets(*pBookmarkStyleSheetPool, aNewGraphicStyles);
++    SdStyleSheetVector aNewCellStyles;
++    pStyleSheetPool->CopyCellSheets(*pBookmarkStyleSheetPool, aNewCellStyles);
++
++    // TODO handle undo of table styles too
++    pStyleSheetPool->CopyTableStyles(*pBookmarkStyleSheetPool);
++
+     /**************************************************************************
+     * Dokument einfuegen
+     **************************************************************************/
+@@ -959,6 +991,17 @@ sal_Bool SdDrawDocument::InsertBookmarkAsPage(
+     // Make absolutely sure no double masterpages are there
+     RemoveUnnecessaryMasterPages(NULL, sal_True, sal_True);
+ 
++    // remove copied styles not used on any inserted page and create
++    // undo records
++    // WARNING: SdMoveStyleSheetsUndoAction clears the passed list of
++    // styles, so it cannot be used after this point
++    lcl_removeUnusedStyles(GetStyleSheetPool(), aNewGraphicStyles);
++    if (!aNewGraphicStyles.empty() && pUndoMgr)
++        pUndoMgr->AddUndoAction(new SdMoveStyleSheetsUndoAction(this, aNewGraphicStyles, sal_True));
++    lcl_removeUnusedStyles(GetStyleSheetPool(), aNewCellStyles);
++    if (!aNewCellStyles.empty() && pUndoMgr)
++        pUndoMgr->AddUndoAction(new SdMoveStyleSheetsUndoAction(this, aNewCellStyles, sal_True));
++
+     if( bUndo )
+         EndUndo();
+     pUndoMgr->LeaveListAction();
+diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx
+index 3625bbf1..2a7698b 100644
+--- a/sd/source/core/stlpool.cxx
++++ b/sd/source/core/stlpool.cxx
+@@ -594,8 +594,24 @@ void SdStyleSheetPool::CopyTableStyles(SdStyleSheetPool& rSourcePool)
+     }
+ }
+ 
++void SdStyleSheetPool::CopyGraphicSheets(SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets)
++{
++    CopySheets( rSourcePool, SD_STYLE_FAMILY_GRAPHICS, rCreatedSheets );
++}
++
++void SdStyleSheetPool::CopyCellSheets(SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets)
++{
++    CopySheets( rSourcePool, SD_STYLE_FAMILY_CELL, rCreatedSheets );
++}
++
+ void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily )
+ {
++    SdStyleSheetVector aTmpSheets;
++    CopySheets(rSourcePool, eFamily, aTmpSheets);
++}
++
++void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, SdStyleSheetVector& rCreatedSheets)
++{
+     String aHelpFile;
+ 
+     sal_uInt32 nCount = rSourcePool.aStyles.size();
+@@ -622,6 +638,8 @@ void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily
+ 
+                 xNewSheet->SetHelpId( aHelpFile, xSheet->GetHelpId( aHelpFile ) );
+                 xNewSheet->GetItemSet().Put( xSheet->GetItemSet() );
++
++                rCreatedSheets.push_back( SdStyleSheetRef( static_cast< SdStyleSheet* >( xNewSheet.get() ) ) );
+             }
+         }
+     }
+diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx
+index 521c7f6..5469663 100644
+--- a/sd/source/core/stlsheet.cxx
++++ b/sd/source/core/stlsheet.cxx
+@@ -45,6 +45,7 @@
+ #include <svl/smplhint.hxx>
+ #include <svl/itemset.hxx>
+ 
++#include <svx/sdr/properties/attributeproperties.hxx>
+ #include <svx/xflbmtit.hxx>
+ #include <svx/xflbstit.hxx>
+ #include <editeng/bulitem.hxx>
+@@ -357,13 +358,16 @@ sal_Bool SdStyleSheet::IsUsed() const
+                 continue;
+ 
+             // NULL-Pointer ist im Listener-Array erlaubt
+-            if (pListener && pListener->ISA(SdrAttrObj))
++            if (pListener)
+             {
+-                bResult = ((SdrAttrObj*)pListener)->IsInserted();
+-            }
+-            else if (pListener && pListener->ISA(SfxStyleSheet))
+-            {
+-                bResult = ((SfxStyleSheet*)pListener)->IsUsed();
++                if (pListener->ISA(sdr::properties::AttributeProperties))
++                {
++                    bResult = true;
++                }
++                else if (pListener->ISA(SfxStyleSheet))
++                {
++                    bResult = ((SfxStyleSheet*)pListener)->IsUsed();
++                }
+             }
+             if (bResult)
+                 break;
+-- 
+1.8.0.2
+
diff --git a/libreoffice.spec b/libreoffice.spec
index ae9f1b7..96cda88 100644
--- a/libreoffice.spec
+++ b/libreoffice.spec
@@ -35,7 +35,7 @@ Summary:        Free Software Productivity Suite
 Name:           libreoffice
 Epoch:          1
 Version:        %{libo_version}.2
-Release:        8%{?dist}
+Release:        9%{?dist}
 License:        (MPLv1.1 or LGPLv3+) and LGPLv3 and LGPLv2+ and BSD and (MPLv1.1 or GPLv2 or LGPLv2 or Netscape) and Public Domain and ASL 2.0 and Artistic
 Group:          Applications/Productivity
 URL:            http://www.documentfoundation.org/develop
@@ -178,6 +178,7 @@ Patch60: 0001-rhbz-890080-crash-in-SwXTextDocument-getRendererCoun.patch
 Patch61: 0001-fdo-59366-Document-Conversion-wizard-enable-StarOffi.patch
 Patch62: 0002-Resolves-fdo-58730-workaround-UL-LR-Space-100-proble.patch
 Patch63: 0001-Resolves-fdo-48569-crash-on-export-to-.docx-of-inlin.patch
+Patch64: 0001-rhbz-760765-copy-custom-styles-on-copy-paste.patch
 
 %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
 %define instdir %{_libdir}
@@ -1071,6 +1072,7 @@ mv -f redhat.soc extras/source/palettes/standard.soc
 %patch61 -p1 -b .fdo-59366-Document-Conversion-wizard-enable-StarOffi.patch
 %patch62 -p1 -b .fdo-58730-workaround-UL-LR-Space-100-proble.patch
 %patch63 -p1 -b .fdo-48569-crash-on-export-to-.docx-of-inlin.patch
+%patch64 -p1 -b .rhbz-760765-copy-custom-styles-on-copy-paste.patch
 
 # TODO: check this
 # these are horribly incomplete--empty translations and copied english
@@ -2357,6 +2359,10 @@ update-desktop-database %{_datadir}/applications &> /dev/null || :
 %endif
 
 %changelog
+* Tue Jan 22 2013 David Tardon <dtardon at redhat.com> - 1:3.5.7.2-9
+- Resolves: rhbz#760765 Impress doesn't copy custom styles from one file
+  to another
+
 * Fri Jan 18 2013 Michael Stahl <mstahl at redhat.com> - 1:3.5.7.2-8
 - Resolves: rhbz#810739 Incorrect displaying attached rtf document
 - Resolves: rhbz#876606 regressions in MSO binary import filters


More information about the scm-commits mailing list