Kaydet (Commit) f8409911 authored tarafından David Tardon's avatar David Tardon

do not second-guess which classes use a stylesheet

Change-Id: I76b23bcdca2e7394fd5ab67e8341f4cdb46f8a64
üst 24578b80
...@@ -349,18 +349,9 @@ bool SdStyleSheet::IsUsed() const ...@@ -349,18 +349,9 @@ bool SdStyleSheet::IsUsed() const
if( pListener == this ) if( pListener == this )
continue; continue;
// NULL-Pointer ist im Listener-Array erlaubt const svl::StyleSheetUser* const pUser(dynamic_cast<svl::StyleSheetUser*>(pListener));
if (pListener) if (pUser)
{ bResult = pUser->isUsedByModel();
if (pListener->ISA(sdr::properties::AttributeProperties))
{
bResult = true;
}
else if (pListener->ISA(SfxStyleSheet))
{
bResult = ((SfxStyleSheet*)pListener)->IsUsed();
}
}
if (bResult) if (bResult)
break; break;
} }
......
...@@ -97,6 +97,7 @@ $(eval $(call gb_Package_add_file,svl_inc,inc/svl/strmadpt.hxx,svl/strmadpt.hxx) ...@@ -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.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/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/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/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/svl.hrc,svl/svl.hrc))
$(eval $(call gb_Package_add_file,svl_inc,inc/svl/svldllapi.h,svl/svldllapi.h)) $(eval $(call gb_Package_add_file,svl_inc,inc/svl/svldllapi.h,svl/svldllapi.h))
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <svl/lstner.hxx> #include <svl/lstner.hxx>
#include <svl/brdcst.hxx> #include <svl/brdcst.hxx>
#include <svl/poolitem.hxx> #include <svl/poolitem.hxx>
#include <svl/stylesheetuser.hxx>
#include <svl/style.hrc> #include <svl/style.hrc>
...@@ -267,7 +268,7 @@ public: ...@@ -267,7 +268,7 @@ public:
//========================================================================= //=========================================================================
class SVL_DLLPUBLIC SfxStyleSheet: public SfxStyleSheetBase, class SVL_DLLPUBLIC SfxStyleSheet: public SfxStyleSheetBase,
public SfxListener, public SfxBroadcaster public SfxListener, public SfxBroadcaster, public svl::StyleSheetUser
{ {
public: public:
TYPEINFO(); TYPEINFO();
...@@ -276,6 +277,9 @@ public: ...@@ -276,6 +277,9 @@ public:
SfxStyleSheet( const SfxStyleSheet& ); SfxStyleSheet( const SfxStyleSheet& );
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
virtual bool isUsedByModel() const;
virtual bool SetParent( const UniString& ); virtual bool SetParent( const UniString& );
protected: protected:
......
/* -*- 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: */
...@@ -913,6 +913,11 @@ void SfxStyleSheet::Notify(SfxBroadcaster& rBC, const SfxHint& rHint ) ...@@ -913,6 +913,11 @@ void SfxStyleSheet::Notify(SfxBroadcaster& rBC, const SfxHint& rHint )
Forward(rBC, rHint); Forward(rBC, rHint);
} }
bool SfxStyleSheet::isUsedByModel() const
{
return IsUsed();
}
//////////////////////// SfxStyleSheetPool /////////////////////////////// //////////////////////// SfxStyleSheetPool ///////////////////////////////
SfxStyleSheetPool::SfxStyleSheetPool( SfxItemPool const& rSet) SfxStyleSheetPool::SfxStyleSheetPool( SfxItemPool const& rSet)
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#define _SDR_PROPERTIES_ATTRIBUTEPROPERTIES_HXX #define _SDR_PROPERTIES_ATTRIBUTEPROPERTIES_HXX
#include <svl/lstner.hxx> #include <svl/lstner.hxx>
#include <svl/stylesheetuser.hxx>
#include <svx/sdr/properties/defaultproperties.hxx> #include <svx/sdr/properties/defaultproperties.hxx>
#include "svx/svxdllapi.h" #include "svx/svxdllapi.h"
...@@ -30,7 +31,7 @@ namespace sdr ...@@ -30,7 +31,7 @@ namespace sdr
{ {
namespace properties 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 // add style sheet, do all the necessary handling
void ImpAddStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr); void ImpAddStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr);
...@@ -82,6 +83,8 @@ namespace sdr ...@@ -82,6 +83,8 @@ namespace sdr
// This is the Notify(...) from 2nd base class SfxListener // This is the Notify(...) from 2nd base class SfxListener
virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint); virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint);
virtual bool isUsedByModel() const;
}; };
} // end of namespace properties } // end of namespace properties
} // end of namespace sdr } // end of namespace sdr
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#ifndef _SVDPAGE_HXX #ifndef _SVDPAGE_HXX
#define _SVDPAGE_HXX #define _SVDPAGE_HXX
#include <svl/stylesheetuser.hxx>
#include <vcl/bitmap.hxx> #include <vcl/bitmap.hxx>
#include <vcl/print.hxx> #include <vcl/print.hxx>
#include <vcl/gdimtf.hxx> #include <vcl/gdimtf.hxx>
...@@ -368,7 +369,7 @@ public: ...@@ -368,7 +369,7 @@ public:
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// class SdrPageProperties // class SdrPageProperties
class SVX_DLLPUBLIC SdrPageProperties : public SfxListener class SVX_DLLPUBLIC SdrPageProperties : public SfxListener, public svl::StyleSheetUser
{ {
private: private:
// data // data
...@@ -391,6 +392,8 @@ public: ...@@ -391,6 +392,8 @@ public:
// Notify(...) from baseclass SfxListener // Notify(...) from baseclass SfxListener
virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint); virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint);
virtual bool isUsedByModel() const;
// data read/write // data read/write
const SfxItemSet& GetItemSet() const; const SfxItemSet& GetItemSet() const;
void PutItemSet(const SfxItemSet& rSet); void PutItemSet(const SfxItemSet& rSet);
......
...@@ -608,6 +608,18 @@ namespace sdr ...@@ -608,6 +608,18 @@ namespace sdr
GetSdrObject().Notify(rBC, rHint); 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 properties
} // end of namespace sdr } // end of namespace sdr
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <cassert>
#include <svx/svdpage.hxx> #include <svx/svdpage.hxx>
...@@ -1196,6 +1197,12 @@ void SdrPageProperties::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint) ...@@ -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 const SfxItemSet& SdrPageProperties::GetItemSet() const
{ {
return *mpProperties; return *mpProperties;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment