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
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;
}
......
......@@ -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))
......
......@@ -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:
......
/* -*- 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 )
Forward(rBC, rHint);
}
bool SfxStyleSheet::isUsedByModel() const
{
return IsUsed();
}
//////////////////////// SfxStyleSheetPool ///////////////////////////////
SfxStyleSheetPool::SfxStyleSheetPool( SfxItemPool const& rSet)
......
......@@ -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
......
......@@ -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);
......
......@@ -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
......
......@@ -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;
......
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