[Libreoffice-commits] .: 4 commits - sd/inc sd/source solenv/bin svl/inc svl/Package_inc.mk svl/source svx/inc svx/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Jan 22 04:43:48 PST 2013
sd/inc/stlpool.hxx | 3 +
sd/source/core/drawdoc3.cxx | 51 +++++++++++++++++++--
sd/source/core/stlpool.cxx | 18 +++++++
sd/source/core/stlsheet.cxx | 13 +----
solenv/bin/linkoo | 2
svl/Package_inc.mk | 1
svl/inc/svl/style.hxx | 6 ++
svl/inc/svl/stylesheetuser.hxx | 38 +++++++++++++++
svl/source/items/style.cxx | 5 ++
svx/inc/svx/sdr/properties/attributeproperties.hxx | 5 +-
svx/inc/svx/svdpage.hxx | 5 +-
svx/source/sdr/properties/attributeproperties.cxx | 12 ++++
svx/source/svdraw/svdpage.cxx | 7 ++
13 files changed, 150 insertions(+), 16 deletions(-)
New commits:
commit f8409911be702c988557903e44783e22a8029769
Author: David Tardon <dtardon at redhat.com>
Date: Tue Jan 22 10:32:32 2013 +0100
do not second-guess which classes use a stylesheet
Change-Id: I76b23bcdca2e7394fd5ab67e8341f4cdb46f8a64
diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx
index f013739..0756e6b 100644
--- a/sd/source/core/stlsheet.cxx
+++ b/sd/source/core/stlsheet.cxx
@@ -349,18 +349,9 @@ bool SdStyleSheet::IsUsed() const
if( pListener == this )
continue;
- // NULL-Pointer ist im Listener-Array erlaubt
- if (pListener)
- {
- if (pListener->ISA(sdr::properties::AttributeProperties))
- {
- bResult = true;
- }
- else if (pListener->ISA(SfxStyleSheet))
- {
- bResult = ((SfxStyleSheet*)pListener)->IsUsed();
- }
- }
+ const svl::StyleSheetUser* const pUser(dynamic_cast<svl::StyleSheetUser*>(pListener));
+ if (pUser)
+ bResult = pUser->isUsedByModel();
if (bResult)
break;
}
diff --git a/svl/Package_inc.mk b/svl/Package_inc.mk
index e518219..5ac424d 100644
--- a/svl/Package_inc.mk
+++ b/svl/Package_inc.mk
@@ -97,6 +97,7 @@ $(eval $(call gb_Package_add_file,svl_inc,inc/svl/strmadpt.hxx,svl/strmadpt.hxx)
$(eval $(call gb_Package_add_file,svl_inc,inc/svl/style.hrc,svl/style.hrc))
$(eval $(call gb_Package_add_file,svl_inc,inc/svl/style.hxx,svl/style.hxx))
$(eval $(call gb_Package_add_file,svl_inc,inc/svl/stylepool.hxx,svl/stylepool.hxx))
+$(eval $(call gb_Package_add_file,svl_inc,inc/svl/stylesheetuser.hxx,svl/stylesheetuser.hxx))
$(eval $(call gb_Package_add_file,svl_inc,inc/svl/svdde.hxx,svl/svdde.hxx))
$(eval $(call gb_Package_add_file,svl_inc,inc/svl/svl.hrc,svl/svl.hrc))
$(eval $(call gb_Package_add_file,svl_inc,inc/svl/svldllapi.h,svl/svldllapi.h))
diff --git a/svl/inc/svl/style.hxx b/svl/inc/svl/style.hxx
index 48557c5..18c0ceb 100644
--- a/svl/inc/svl/style.hxx
+++ b/svl/inc/svl/style.hxx
@@ -34,6 +34,7 @@
#include <svl/lstner.hxx>
#include <svl/brdcst.hxx>
#include <svl/poolitem.hxx>
+#include <svl/stylesheetuser.hxx>
#include <svl/style.hrc>
@@ -267,7 +268,7 @@ public:
//=========================================================================
class SVL_DLLPUBLIC SfxStyleSheet: public SfxStyleSheetBase,
- public SfxListener, public SfxBroadcaster
+ public SfxListener, public SfxBroadcaster, public svl::StyleSheetUser
{
public:
TYPEINFO();
@@ -276,6 +277,9 @@ public:
SfxStyleSheet( const SfxStyleSheet& );
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ virtual bool isUsedByModel() const;
+
virtual bool SetParent( const UniString& );
protected:
diff --git a/svl/inc/svl/stylesheetuser.hxx b/svl/inc/svl/stylesheetuser.hxx
new file mode 100644
index 0000000..787263f
--- /dev/null
+++ b/svl/inc/svl/stylesheetuser.hxx
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef SVL_STYLESHEETUSER_HXX_INCLUDED
+#define SVL_STYLESHEETUSER_HXX_INCLUDED
+
+namespace svl
+{
+
+/** Test whether object that uses a stylesheet is used itself.
+
+ This interface should be implemented by all classes that use
+ a SfxStyleSheet (and listen on it). It can be queried by the stylesheet
+ to determine if it is really used.
+ */
+class StyleSheetUser
+{
+public:
+ /** Test whether this object is used.
+
+ @return true, if the object is used, false otherwise
+ */
+ virtual bool isUsedByModel() const = 0;
+protected:
+ ~StyleSheetUser() {}
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx
index 6df5bfa..812567c 100644
--- a/svl/source/items/style.cxx
+++ b/svl/source/items/style.cxx
@@ -913,6 +913,11 @@ void SfxStyleSheet::Notify(SfxBroadcaster& rBC, const SfxHint& rHint )
Forward(rBC, rHint);
}
+bool SfxStyleSheet::isUsedByModel() const
+{
+ return IsUsed();
+}
+
//////////////////////// SfxStyleSheetPool ///////////////////////////////
SfxStyleSheetPool::SfxStyleSheetPool( SfxItemPool const& rSet)
diff --git a/svx/inc/svx/sdr/properties/attributeproperties.hxx b/svx/inc/svx/sdr/properties/attributeproperties.hxx
index 12d8e20..9f3e4d9 100644
--- a/svx/inc/svx/sdr/properties/attributeproperties.hxx
+++ b/svx/inc/svx/sdr/properties/attributeproperties.hxx
@@ -21,6 +21,7 @@
#define _SDR_PROPERTIES_ATTRIBUTEPROPERTIES_HXX
#include <svl/lstner.hxx>
+#include <svl/stylesheetuser.hxx>
#include <svx/sdr/properties/defaultproperties.hxx>
#include "svx/svxdllapi.h"
@@ -30,7 +31,7 @@ namespace sdr
{
namespace properties
{
- class SVX_DLLPUBLIC AttributeProperties : public DefaultProperties, public SfxListener
+ class SVX_DLLPUBLIC AttributeProperties : public DefaultProperties, public SfxListener, public svl::StyleSheetUser
{
// add style sheet, do all the necessary handling
void ImpAddStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr);
@@ -82,6 +83,8 @@ namespace sdr
// This is the Notify(...) from 2nd base class SfxListener
virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint);
+
+ virtual bool isUsedByModel() const;
};
} // end of namespace properties
} // end of namespace sdr
diff --git a/svx/inc/svx/svdpage.hxx b/svx/inc/svx/svdpage.hxx
index 8cd9eec..9d9e3f2 100644
--- a/svx/inc/svx/svdpage.hxx
+++ b/svx/inc/svx/svdpage.hxx
@@ -20,6 +20,7 @@
#ifndef _SVDPAGE_HXX
#define _SVDPAGE_HXX
+#include <svl/stylesheetuser.hxx>
#include <vcl/bitmap.hxx>
#include <vcl/print.hxx>
#include <vcl/gdimtf.hxx>
@@ -368,7 +369,7 @@ public:
////////////////////////////////////////////////////////////////////////////////////////////////////
// class SdrPageProperties
-class SVX_DLLPUBLIC SdrPageProperties : public SfxListener
+class SVX_DLLPUBLIC SdrPageProperties : public SfxListener, public svl::StyleSheetUser
{
private:
// data
@@ -391,6 +392,8 @@ public:
// Notify(...) from baseclass SfxListener
virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint);
+ virtual bool isUsedByModel() const;
+
// data read/write
const SfxItemSet& GetItemSet() const;
void PutItemSet(const SfxItemSet& rSet);
diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx
index 538e4f0..54386de 100644
--- a/svx/source/sdr/properties/attributeproperties.cxx
+++ b/svx/source/sdr/properties/attributeproperties.cxx
@@ -608,6 +608,18 @@ namespace sdr
GetSdrObject().Notify(rBC, rHint);
}
}
+
+ bool AttributeProperties::isUsedByModel() const
+ {
+ const SdrObject& rObj(GetSdrObject());
+ if (rObj.IsInserted())
+ {
+ const SdrPage* const pPage(rObj.GetPage());
+ if (pPage && pPage->IsInserted())
+ return true;
+ }
+ return false;
+ }
} // end of namespace properties
} // end of namespace sdr
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index 5ed24f5..50e4e3b 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <cassert>
#include <svx/svdpage.hxx>
@@ -1196,6 +1197,12 @@ void SdrPageProperties::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
}
}
+bool SdrPageProperties::isUsedByModel() const
+{
+ assert(mpSdrPage);
+ return mpSdrPage->IsInserted();
+}
+
const SfxItemSet& SdrPageProperties::GetItemSet() const
{
return *mpProperties;
commit 24578b804007d8c3201e5ed32b8485e1725c33c1
Author: David Tardon <dtardon at redhat.com>
Date: Thu Jan 17 15:01:32 2013 +0100
rhbz#760765 copy custom styles on copy & paste
Change-Id: Icaacf3bc1a02a017692432aec36aba06d3f5dde5
diff --git a/sd/inc/stlpool.hxx b/sd/inc/stlpool.hxx
index 9e76c2a..4833dd8 100644
--- a/sd/inc/stlpool.hxx
+++ b/sd/inc/stlpool.hxx
@@ -80,6 +80,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();
@@ -121,6 +123,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 e7ac380..b18c254 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -357,6 +357,26 @@ sal_Bool SdDrawDocument::InsertBookmark(
return bOK;
}
+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(
const std::vector<rtl::OUString> &rBookmarkList,
std::vector<rtl::OUString> *pExchangeList, // Liste der zu verwendenen Namen
@@ -484,8 +504,8 @@ sal_Bool SdDrawDocument::InsertBookmarkAsPage(
/**************************************************************************
* Die tatsaechlich benoetigten Vorlagen kopieren
**************************************************************************/
- SdStyleSheetPool* pBookmarkStyleSheetPool =
- (SdStyleSheetPool*) pBookmarkDoc->GetStyleSheetPool();
+ 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!
@@ -498,7 +518,7 @@ sal_Bool SdDrawDocument::InsertBookmarkAsPage(
SdStyleSheetVector aCreatedStyles;
String layoutName = *pIter;
- ((SdStyleSheetPool*)GetStyleSheetPool())->CopyLayoutSheets(layoutName, *pBookmarkStyleSheetPool,aCreatedStyles);
+ pStyleSheetPool->CopyLayoutSheets(layoutName, *pBookmarkStyleSheetPool,aCreatedStyles);
if(!aCreatedStyles.empty())
{
@@ -510,6 +530,18 @@ sal_Bool SdDrawDocument::InsertBookmarkAsPage(
}
}
+ // 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
**************************************************************************/
@@ -910,6 +942,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 078a64d..cfe6c82 100644
--- a/sd/source/core/stlpool.cxx
+++ b/sd/source/core/stlpool.cxx
@@ -582,8 +582,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();
@@ -610,6 +626,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 ecd84d7..f013739 100644
--- a/sd/source/core/stlsheet.cxx
+++ b/sd/source/core/stlsheet.cxx
@@ -35,6 +35,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>
@@ -349,13 +350,16 @@ 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;
commit 34add900d03aa1ac194152f9f96d5b8b852a1175
Author: David Tardon <dtardon at redhat.com>
Date: Wed Jan 16 14:06:21 2013 +0100
use already defined variable
Change-Id: Ibadc8327cef327625d6b4663c1487b126e2e6920
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index a3ff2ec..e7ac380 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -419,7 +419,7 @@ sal_Bool SdDrawDocument::InsertBookmarkAsPage(
Orientation eOrient = pRefPage->GetOrientation();
SdPage* pNPage = GetSdPage(0, PK_NOTES);
- Size aNSize(GetSdPage(0, PK_NOTES)->GetSize());
+ Size aNSize(pNPage->GetSize());
sal_Int32 nNLeft = pNPage->GetLftBorder();
sal_Int32 nNRight = pNPage->GetRgtBorder();
sal_Int32 nNUpper = pNPage->GetUppBorder();
commit c6a5e93b79e01e13185a909106d9dd6a68be63f6
Author: David Tardon <dtardon at redhat.com>
Date: Tue Jan 8 10:30:45 2013 +0100
clean linkoo output
Change-Id: I5345a062206a065f01bb19ca808c467d94da5259
diff --git a/solenv/bin/linkoo b/solenv/bin/linkoo
index 7b9ee4a..6f6e096 100755
--- a/solenv/bin/linkoo
+++ b/solenv/bin/linkoo
@@ -455,6 +455,7 @@ sub link_ui_files()
my @modules = get_modules( $OOO_BUILD, $TARGET );
+ print "ui case:";
# Search the files in the source tree
for my $dest ( @files )
{
@@ -500,6 +501,7 @@ sub link_ui_files()
do_link ( $src_dir, $dest_dir, $name, $name );
}
}
+ print "\n";
}
evilness ('undo');
More information about the Libreoffice-commits
mailing list