summaryrefslogtreecommitdiffstats
path: root/sc
diff options
context:
space:
mode:
authorNiklas Nebel <nn@openoffice.org>2001-02-15 17:07:10 +0000
committerNiklas Nebel <nn@openoffice.org>2001-02-15 17:07:10 +0000
commit8dd9f54c38cc93d47481f76dbb46062694ee72a0 (patch)
treecda7f88409bf707e65709225137825b1549c42ea /sc
parentexport/import of visarea added (diff)
downloadcore-8dd9f54c38cc93d47481f76dbb46062694ee72a0.tar.gz
core-8dd9f54c38cc93d47481f76dbb46062694ee72a0.zip
fill EditEngine for header/footer edit source only if data changed
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/editsrc.hxx19
-rw-r--r--sc/inc/textuno.hxx12
-rw-r--r--sc/source/ui/unoobj/editsrc.cxx52
-rw-r--r--sc/source/ui/unoobj/textuno.cxx16
4 files changed, 85 insertions, 14 deletions
diff --git a/sc/inc/editsrc.hxx b/sc/inc/editsrc.hxx
index 5dd92d73745c..d11125861371 100644
--- a/sc/inc/editsrc.hxx
+++ b/sc/inc/editsrc.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: editsrc.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: nn $ $Date: 2001-01-18 15:52:29 $
+ * last change: $Author: nn $ $Date: 2001-02-15 18:05:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -83,6 +83,19 @@ class ScDocShell;
class ScHeaderFooterContentObj;
+class ScHeaderFooterChangedHint : public SfxHint
+{
+ USHORT nPart;
+
+public:
+ TYPEINFO();
+ ScHeaderFooterChangedHint(USHORT nP);
+ ~ScHeaderFooterChangedHint();
+
+ USHORT GetPart() const { return nPart; }
+};
+
+
class ScHeaderFooterEditSource : public SvxEditSource, public SfxListener
{
private:
@@ -90,6 +103,8 @@ private:
USHORT nPart;
ScEditEngineDefaulter* pEditEngine;
SvxEditEngineForwarder* pForwarder;
+ BOOL bDataValid;
+ BOOL bInUpdate;
public:
ScHeaderFooterEditSource( ScHeaderFooterContentObj* pContent,
diff --git a/sc/inc/textuno.hxx b/sc/inc/textuno.hxx
index 284e52e8a361..74596e01a605 100644
--- a/sc/inc/textuno.hxx
+++ b/sc/inc/textuno.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: textuno.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: nn $ $Date: 2001-01-18 15:55:11 $
+ * last change: $Author: nn $ $Date: 2001-02-15 18:05:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -66,6 +66,10 @@
#include <svx/unotext.hxx>
#endif
+#ifndef _SFXBRDCST_HXX
+#include <svtools/brdcst.hxx>
+#endif
+
#ifndef _COM_SUN_STAR_TEXT_XTEXTFIELDSSUPPLIER_HPP_
#include <com/sun/star/text/XTextFieldsSupplier.hpp>
#endif
@@ -116,6 +120,7 @@ private:
EditTextObject* pLeftText;
EditTextObject* pCenterText;
EditTextObject* pRightText;
+ SfxBroadcaster aBC;
public:
ScHeaderFooterContentObj();
@@ -129,6 +134,9 @@ public:
const EditTextObject* GetCenterEditObject() const { return pCenterText; }
const EditTextObject* GetRightEditObject() const { return pRightText; }
+ void AddListener( SfxListener& rListener );
+ void RemoveListener( SfxListener& rListener );
+
void UpdateText( USHORT nPart, EditEngine& rSource );
// XHeaderFooterContent
diff --git a/sc/source/ui/unoobj/editsrc.cxx b/sc/source/ui/unoobj/editsrc.cxx
index afec033f1872..1df97cbade69 100644
--- a/sc/source/ui/unoobj/editsrc.cxx
+++ b/sc/source/ui/unoobj/editsrc.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: editsrc.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: nn $ $Date: 2001-01-18 15:54:02 $
+ * last change: $Author: nn $ $Date: 2001-02-15 18:07:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -88,24 +88,43 @@
//------------------------------------------------------------------------
+TYPEINIT1( ScHeaderFooterChangedHint, SfxHint );
+
+ScHeaderFooterChangedHint::ScHeaderFooterChangedHint(USHORT nP) :
+ nPart( nP )
+{
+}
+
+ScHeaderFooterChangedHint::~ScHeaderFooterChangedHint()
+{
+}
+
+//------------------------------------------------------------------------
+
ScHeaderFooterEditSource::ScHeaderFooterEditSource( ScHeaderFooterContentObj* pContent,
USHORT nP ) :
pContentObj( pContent ),
nPart( nP ),
pEditEngine( NULL ),
- pForwarder( NULL )
-
+ pForwarder( NULL ),
+ bDataValid( FALSE ),
+ bInUpdate( FALSE )
{
- if (pContentObj) // pContentObj kann 0 sein bei getReflection-Krempel
- pContentObj->acquire(); // darf nicht wegkommen
+ if (pContentObj) // pContentObj can be 0 if constructed via getReflection
+ {
+ pContentObj->acquire(); // must not go away
- //! bDataValid oder so...
+ pContentObj->AddListener( *this );
+ }
}
ScHeaderFooterEditSource::~ScHeaderFooterEditSource()
{
ScUnoGuard aGuard; // needed for EditEngine dtor
+ if (pContentObj)
+ pContentObj->RemoveListener( *this );
+
delete pForwarder;
delete pEditEngine;
@@ -148,6 +167,9 @@ SvxTextForwarder* ScHeaderFooterEditSource::GetTextForwarder()
pForwarder = new SvxEditEngineForwarder(*pEditEngine);
}
+ if (bDataValid)
+ return pForwarder;
+
if (pContentObj)
{
const EditTextObject* pData;
@@ -162,18 +184,32 @@ SvxTextForwarder* ScHeaderFooterEditSource::GetTextForwarder()
pEditEngine->SetText(*pData);
}
+ bDataValid = TRUE;
return pForwarder;
}
void ScHeaderFooterEditSource::UpdateData()
{
if ( pContentObj && pEditEngine )
+ {
+ bInUpdate = TRUE; // don't reset bDataValid during UpdateText
+
pContentObj->UpdateText( nPart, *pEditEngine );
+
+ bInUpdate = FALSE;
+ }
}
void ScHeaderFooterEditSource::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
- // spaeter...
+ if ( rHint.ISA( ScHeaderFooterChangedHint ) )
+ {
+ if ( ((const ScHeaderFooterChangedHint&)rHint).GetPart() == nPart )
+ {
+ if (!bInUpdate) // not for own updates
+ bDataValid = FALSE; // text has to be fetched again
+ }
+ }
}
//------------------------------------------------------------------------
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
index 4e0768921efa..1358efdfc542 100644
--- a/sc/source/ui/unoobj/textuno.cxx
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: textuno.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: nn $ $Date: 2001-01-18 19:55:17 $
+ * last change: $Author: nn $ $Date: 2001-02-15 18:07:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -169,6 +169,16 @@ ScHeaderFooterContentObj::~ScHeaderFooterContentObj()
delete pRightText;
}
+void ScHeaderFooterContentObj::AddListener( SfxListener& rListener )
+{
+ rListener.StartListening( aBC );
+}
+
+void ScHeaderFooterContentObj::RemoveListener( SfxListener& rListener )
+{
+ rListener.EndListening( aBC );
+}
+
void ScHeaderFooterContentObj::UpdateText( USHORT nPart, EditEngine& rSource )
{
EditTextObject* pNew = rSource.CreateTextObject();
@@ -187,6 +197,8 @@ void ScHeaderFooterContentObj::UpdateText( USHORT nPart, EditEngine& rSource )
pRightText = pNew;
break;
}
+
+ aBC.Broadcast( ScHeaderFooterChangedHint( nPart ) );
}
// XHeaderFooterContent