diff options
author | Sascha Ballach <sab@openoffice.org> | 2002-05-24 14:05:28 +0000 |
---|---|---|
committer | Sascha Ballach <sab@openoffice.org> | 2002-05-24 14:05:28 +0000 |
commit | 44913d97cb258a18baff522add40ed730ac4aef2 (patch) | |
tree | 041ca7dabc38fa71937d876b5b09ec4dc38a5acf /sc/source/ui | |
parent | 882d15f01fd7341c1850973d60c9b7bacc7f5e8c (diff) |
#95584#; add Forwarder of the preview
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleText.cxx | 264 | ||||
-rw-r--r-- | sc/source/ui/inc/AccessibleText.hxx | 100 |
2 files changed, 341 insertions, 23 deletions
diff --git a/sc/source/ui/Accessibility/AccessibleText.cxx b/sc/source/ui/Accessibility/AccessibleText.cxx index 2ef700a12d99..2569aef3ea55 100644 --- a/sc/source/ui/Accessibility/AccessibleText.cxx +++ b/sc/source/ui/Accessibility/AccessibleText.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AccessibleText.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: thb $ $Date: 2002-04-26 11:17:58 $ + * last change: $Author: sab $ $Date: 2002-05-24 15:05:28 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,9 +59,14 @@ * ************************************************************************/ +#include "scitems.hxx" +#include <svx/eeitem.hxx> +#define ITEMID_FIELD EE_FEATURE_FIELD + #include <memory> #include "AccessibleText.hxx" + #ifndef SC_TABVWSH_HXX #include "tabvwsh.hxx" #endif @@ -83,6 +88,11 @@ #ifndef SC_PREVLOC_HXX #include "prevloc.hxx" #endif +#ifndef SC_UNOGUARD_HXX +#include "unoguard.hxx" +#endif +#include "patattr.hxx" + #ifndef _SVX_UNOFORED_HXX #include <svx/unofored.hxx> @@ -96,6 +106,12 @@ #ifndef _SV_VIRDEV_HXX #include <vcl/virdev.hxx> #endif +#ifndef _EDITOBJ_HXX +#include <svx/editobj.hxx> +#endif +#ifndef _SVX_ADJITEM_HXX +#include <svx/adjitem.hxx> +#endif class ScViewForwarder : public SvxViewForwarder { @@ -496,7 +512,7 @@ void ScEditViewForwarder::GrabFocus() ScAccessibleCellTextData::ScAccessibleCellTextData(ScTabViewShell* pViewShell, const ScAddress& rP, ScSplitPos eSplitPos) - : ScAccessibleTextData(GetDocShell(pViewShell), rP), + : ScAccessibleCellBaseTextData(GetDocShell(pViewShell), rP), mpViewShell(pViewShell), meSplitPos(eSplitPos), mpViewForwarder(NULL), @@ -523,7 +539,7 @@ void ScAccessibleCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint mpViewShell = NULL; // invalid now } } - ScCellTextData::Notify(rBC, rHint); + ScAccessibleCellBaseTextData::Notify(rBC, rHint); } ScAccessibleTextData* ScAccessibleCellTextData::Clone() const @@ -614,7 +630,7 @@ IMPL_LINK(ScAccessibleCellTextData, NotifyHdl, EENotify*, aNotify) { if( aNotify ) { - ::std::auto_ptr< SfxHint > aHint( SvxEditSourceHintTranslator::EENotification2Hint( aNotify) ); + ::std::auto_ptr< SfxHint > aHint = SvxEditSourceHintTranslator::EENotification2Hint( aNotify ); if( aHint.get() ) GetBroadcaster().Broadcast( *aHint.get() ); @@ -635,7 +651,7 @@ ScDocShell* ScAccessibleCellTextData::GetDocShell(ScTabViewShell* pViewShell) ScAccessiblePreviewCellTextData::ScAccessiblePreviewCellTextData(ScPreviewShell* pViewShell, const ScAddress& rP) - : ScAccessibleTextData(GetDocShell(pViewShell), rP), + : ScAccessibleCellBaseTextData(GetDocShell(pViewShell), rP), mpViewShell(pViewShell), mpViewForwarder(NULL) { @@ -657,7 +673,7 @@ void ScAccessiblePreviewCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint mpViewShell = NULL; // invalid now } } - ScCellTextData::Notify(rBC, rHint); + ScAccessibleCellBaseTextData::Notify(rBC, rHint); } ScAccessibleTextData* ScAccessiblePreviewCellTextData::Clone() const @@ -697,7 +713,7 @@ IMPL_LINK(ScAccessiblePreviewCellTextData, NotifyHdl, EENotify*, aNotify) { if( aNotify ) { - ::std::auto_ptr< SfxHint > aHint( SvxEditSourceHintTranslator::EENotification2Hint( aNotify) ); + ::std::auto_ptr< SfxHint > aHint = SvxEditSourceHintTranslator::EENotification2Hint( aNotify); if( aHint.get() ) GetBroadcaster().Broadcast( *aHint.get() ); @@ -718,7 +734,7 @@ ScDocShell* ScAccessiblePreviewCellTextData::GetDocShell(ScPreviewShell* pViewSh ScAccessiblePreviewHeaderCellTextData::ScAccessiblePreviewHeaderCellTextData(ScPreviewShell* pViewShell, const String& rText, const ScAddress& rP, sal_Bool bColHeader, sal_Bool bRowHeader) - : ScAccessibleTextData(GetDocShell(pViewShell), rP), + : ScAccessibleCellBaseTextData(GetDocShell(pViewShell), rP), mpViewShell(pViewShell), mpViewForwarder(NULL), maText(rText), @@ -743,7 +759,7 @@ void ScAccessiblePreviewHeaderCellTextData::Notify( SfxBroadcaster& rBC, const S mpViewShell = NULL; // invalid now } } - ScCellTextData::Notify(rBC, rHint); + ScAccessibleCellBaseTextData::Notify(rBC, rHint); } ScAccessibleTextData* ScAccessiblePreviewHeaderCellTextData::Clone() const @@ -794,9 +810,8 @@ SvxTextForwarder* ScAccessiblePreviewHeaderCellTextData::GetTextForwarder() Point aPoint; Rectangle aVisRect( aPoint, aOutputSize ); Size aSize(mpViewShell->GetLocationData().GetHeaderCellOutputRect(aVisRect, aCellPos, mbColHeader).GetSize()); - Window* pWin = mpViewShell->GetWindow(); - if (pWin) - pWin->PixelToLogic(aSize, pEditEngine->GetRefMapMode()); + if (pWindow) + pWindow->PixelToLogic(aSize, pEditEngine->GetRefMapMode()); pEditEngine->SetPaperSize(aSize); } pEditEngine->SetText( maText ); @@ -821,7 +836,7 @@ IMPL_LINK(ScAccessiblePreviewHeaderCellTextData, NotifyHdl, EENotify*, aNotify) { if( aNotify ) { - ::std::auto_ptr< SfxHint > aHint( SvxEditSourceHintTranslator::EENotification2Hint( aNotify) ); + ::std::auto_ptr< SfxHint > aHint = SvxEditSourceHintTranslator::EENotification2Hint( aNotify); if( aHint.get() ) GetBroadcaster().Broadcast( *aHint.get() ); @@ -838,3 +853,224 @@ ScDocShell* ScAccessiblePreviewHeaderCellTextData::GetDocShell(ScPreviewShell* p return pDocSh; } +ScAccessibleHeaderTextData::ScAccessibleHeaderTextData(ScPreviewShell* pViewShell, + const EditTextObject* pEditObj, sal_Bool bHeader, SvxAdjust eAdjust) + : + mpViewShell(pViewShell), + mpEditObj(pEditObj), + mbHeader(bHeader), + mpEditEngine(NULL), + mpForwarder(NULL), + mpDocSh(NULL), + mpViewForwarder(NULL), + mbDataValid(sal_False), + meAdjust(eAdjust) +{ + if (pViewShell && pViewShell->GetDocument()) + mpDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell(); + if (mpDocSh) + mpDocSh->GetDocument()->AddUnoObject(*this); +} + +ScAccessibleHeaderTextData::~ScAccessibleHeaderTextData() +{ + ScUnoGuard aGuard; // needed for EditEngine dtor + + if (mpDocSh) + mpDocSh->GetDocument()->RemoveUnoObject(*this); + delete mpEditEngine; + delete mpForwarder; +} + +ScAccessibleTextData* ScAccessibleHeaderTextData::Clone() const +{ + return new ScAccessibleHeaderTextData(mpViewShell, mpEditObj, mbHeader, meAdjust); +} + +void ScAccessibleHeaderTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) +{ + if ( rHint.ISA( SfxSimpleHint ) ) + { + ULONG nId = ((const SfxSimpleHint&)rHint).GetId(); + if ( nId == SFX_HINT_DYING ) + { + mpViewShell = NULL;// invalid now + mpDocSh = NULL; + } + } +} + +SvxTextForwarder* ScAccessibleHeaderTextData::GetTextForwarder() +{ + if (!mpEditEngine) + { + SfxItemPool* pEnginePool = EditEngine::CreatePool(); + pEnginePool->FreezeIdRanges(); + ScHeaderEditEngine* pHdrEngine = new ScHeaderEditEngine( pEnginePool, TRUE ); + + pHdrEngine->EnableUndo( FALSE ); + pHdrEngine->SetRefMapMode( MAP_TWIP ); + + // default font must be set, independently of document + // -> use global pool from module + + SfxItemSet aDefaults( pHdrEngine->GetEmptyItemSet() ); + const ScPatternAttr& rPattern = (const ScPatternAttr&)SC_MOD()->GetPool().GetDefaultItem(ATTR_PATTERN); + rPattern.FillEditItemSet( &aDefaults ); + // FillEditItemSet adjusts font height to 1/100th mm, + // but for header/footer twips is needed, as in the PatternAttr: + aDefaults.Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT ); + aDefaults.Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK ); + aDefaults.Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL ); + aDefaults.Put( SvxAdjustItem( meAdjust, EE_PARA_JUST ) ); + pHdrEngine->SetDefaults( aDefaults ); + + ScHeaderFieldData aData; + if (mpViewShell) + mpViewShell->FillFieldData(aData); + else + ScHeaderFooterTextObj::FillDummyFieldData( aData ); + pHdrEngine->SetData( aData ); + + mpEditEngine = pHdrEngine; + mpForwarder = new SvxEditEngineForwarder(*mpEditEngine); + } + + if (mbDataValid) + return mpForwarder; + + if ( mpViewShell ) + { + Rectangle aVisRect; + mpViewShell->GetLocationData().GetHeaderPosition(aVisRect); + Size aSize(aVisRect.GetSize()); + Window* pWin = mpViewShell->GetWindow(); + if (pWin) + pWin->PixelToLogic(aSize, mpEditEngine->GetRefMapMode()); + mpEditEngine->SetPaperSize(aSize); + } + if (mpEditObj) + mpEditEngine->SetText(*mpEditObj); + + mbDataValid = sal_True; + return mpForwarder; +} + +SvxViewForwarder* ScAccessibleHeaderTextData::GetViewForwarder() +{ + if (!mpViewForwarder) + mpViewForwarder = new ScPreviewViewForwarder(mpViewShell); + return mpViewForwarder; +} + +ScAccessibleNoteTextData::ScAccessibleNoteTextData(ScPreviewShell* pViewShell, + const String& sText, const ScAddress& aCellPos, sal_Bool bMarkNote) + : + mpViewShell(pViewShell), + msText(sText), + mpEditEngine(NULL), + mpForwarder(NULL), + mpDocSh(NULL), + mpViewForwarder(NULL), + mbDataValid(sal_False), + maCellPos(aCellPos), + mbMarkNote(bMarkNote) +{ + if (pViewShell && pViewShell->GetDocument()) + mpDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell(); + if (mpDocSh) + mpDocSh->GetDocument()->AddUnoObject(*this); +} + +ScAccessibleNoteTextData::~ScAccessibleNoteTextData() +{ + ScUnoGuard aGuard; // needed for EditEngine dtor + + if (mpDocSh) + mpDocSh->GetDocument()->RemoveUnoObject(*this); + delete mpEditEngine; + delete mpForwarder; +} + +ScAccessibleTextData* ScAccessibleNoteTextData::Clone() const +{ + return new ScAccessibleNoteTextData(mpViewShell, msText, maCellPos, mbMarkNote); +} + +void ScAccessibleNoteTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) +{ + if ( rHint.ISA( SfxSimpleHint ) ) + { + ULONG nId = ((const SfxSimpleHint&)rHint).GetId(); + if ( nId == SFX_HINT_DYING ) + { + mpViewShell = NULL;// invalid now + mpDocSh = NULL; + } + } +} + +SvxTextForwarder* ScAccessibleNoteTextData::GetTextForwarder() +{ + if (!mpEditEngine) + { + if ( mpDocSh ) + { + ScDocument* pDoc = mpDocSh->GetDocument(); + mpEditEngine = pDoc->CreateFieldEditEngine(); + } + else + { + SfxItemPool* pEnginePool = EditEngine::CreatePool(); + pEnginePool->FreezeIdRanges(); + mpEditEngine = new ScFieldEditEngine( pEnginePool, NULL, TRUE ); + } +#if SUPD > 600 + // currently, GetPortions doesn't work if UpdateMode is FALSE, + // this will be fixed (in EditEngine) by src600 +// pEditEngine->SetUpdateMode( FALSE ); +#endif + mpEditEngine->EnableUndo( FALSE ); + if (mpDocSh) + mpEditEngine->SetRefDevice(mpDocSh->GetVirtualDevice_100th_mm()); + else + mpEditEngine->SetRefMapMode( MAP_100TH_MM ); + mpForwarder = new SvxEditEngineForwarder(*mpEditEngine); + } + + if (mbDataValid) + return mpForwarder; + + if (msText.Len() && mpEditEngine) + { + + if ( mpViewShell ) + { + Size aOutputSize; + Window* pWindow = mpViewShell->GetWindow(); + if ( pWindow ) + aOutputSize = pWindow->GetOutputSizePixel(); + Point aPoint; + Rectangle aVisRect( aPoint, aOutputSize ); + Size aSize(mpViewShell->GetLocationData().GetNoteInRangeOutputRect(aVisRect, mbMarkNote, maCellPos).GetSize()); + if (pWindow) + pWindow->PixelToLogic(aSize, mpEditEngine->GetRefMapMode()); + mpEditEngine->SetPaperSize(aSize); + } + mpEditEngine->SetText( msText ); + } + + mbDataValid = TRUE; + + if (mpEditEngine) + mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleCellTextData, NotifyHdl) ); + + return mpForwarder; +} + +SvxViewForwarder* ScAccessibleNoteTextData::GetViewForwarder() +{ + if (!mpViewForwarder) + mpViewForwarder = new ScPreviewViewForwarder(mpViewShell); + return mpViewForwarder; +} diff --git a/sc/source/ui/inc/AccessibleText.hxx b/sc/source/ui/inc/AccessibleText.hxx index 78c86b1a3748..1cd099d47ac1 100644 --- a/sc/source/ui/inc/AccessibleText.hxx +++ b/sc/source/ui/inc/AccessibleText.hxx @@ -2,9 +2,9 @@ * * $RCSfile: AccessibleText.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: sab $ $Date: 2002-04-08 15:01:23 $ + * last change: $Author: sab $ $Date: 2002-05-24 15:04:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,19 +72,22 @@ #include "viewdata.hxx" #endif +#ifndef _SVX_SVXENUM_HXX +#include <svx/svxenum.hxx> +#endif + class ScCellTextData; class ScDocShell; class ScViewForwarder; class ScPreviewViewForwarder; class ScEditViewForwarder; class ScPreviewShell; +class EditTextObject; -class ScAccessibleTextData : public ScCellTextData +class ScAccessibleTextData : public SfxListener { public: - ScAccessibleTextData(ScDocShell* pDocShell, - const ScAddress& rP) - : ScCellTextData(pDocShell, rP) {} + ScAccessibleTextData() {} virtual ~ScAccessibleTextData() {} virtual ScAccessibleTextData* Clone() const = NULL; @@ -96,6 +99,10 @@ public: virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate ) = NULL; virtual SfxBroadcaster& GetBroadcaster() const { return maBroadcaster; } + virtual void UpdateData() = NULL; + virtual void SetDoUpdate(sal_Bool bValue) = NULL; + virtual sal_Bool IsDirty() const = NULL; + private: mutable SfxBroadcaster maBroadcaster; @@ -103,9 +110,24 @@ private: ScSharedCellEditSource* GetOriginalSource() { return NULL; } }; +class ScAccessibleCellBaseTextData : public ScAccessibleTextData, + public ScCellTextData +{ +public: + ScAccessibleCellBaseTextData(ScDocShell* pDocShell, + const ScAddress& rP) + : ScCellTextData(pDocShell, rP) {} + virtual ~ScAccessibleCellBaseTextData() {} + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { ScCellTextData::Notify(rBC, rHint); } + + virtual void UpdateData() { ScCellTextData::UpdateData(); } + virtual void SetDoUpdate(sal_Bool bValue) { ScCellTextData::SetDoUpdate(bValue); } + virtual sal_Bool IsDirty() const { return ScCellTextData::IsDirty(); } +}; + // ScAccessibleCellTextData: shared data between sub objects of a accessible cell text object -class ScAccessibleCellTextData : public ScAccessibleTextData +class ScAccessibleCellTextData : public ScAccessibleCellBaseTextData { public: ScAccessibleCellTextData(ScTabViewShell* pViewShell, @@ -134,7 +156,7 @@ private: ScDocShell* GetDocShell(ScTabViewShell* pViewShell); }; -class ScAccessiblePreviewCellTextData : public ScAccessibleTextData +class ScAccessiblePreviewCellTextData : public ScAccessibleCellBaseTextData { public: ScAccessiblePreviewCellTextData(ScPreviewShell* pViewShell, @@ -160,7 +182,7 @@ private: ScDocShell* GetDocShell(ScPreviewShell* pViewShell); }; -class ScAccessiblePreviewHeaderCellTextData : public ScAccessibleTextData +class ScAccessiblePreviewHeaderCellTextData : public ScAccessibleCellBaseTextData { public: ScAccessiblePreviewHeaderCellTextData(ScPreviewShell* pViewShell, @@ -189,4 +211,64 @@ private: ScDocShell* GetDocShell(ScPreviewShell* pViewShell); }; +class ScAccessibleHeaderTextData : public ScAccessibleTextData +{ +public: + ScAccessibleHeaderTextData(ScPreviewShell* pViewShell, + const EditTextObject* pEditObj, sal_Bool bHeader, SvxAdjust eAdjust); + virtual ~ScAccessibleHeaderTextData(); + + virtual ScAccessibleTextData* Clone() const; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + + virtual SvxTextForwarder* GetTextForwarder(); + virtual SvxViewForwarder* GetViewForwarder(); + virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate ) { return NULL; } + + virtual void UpdateData() { } + virtual void SetDoUpdate(sal_Bool bValue) { } + virtual sal_Bool IsDirty() const { return sal_False; } +private: + ScPreviewViewForwarder* mpViewForwarder; + ScPreviewShell* mpViewShell; + ScEditEngineDefaulter* mpEditEngine; + SvxEditEngineForwarder* mpForwarder; + ScDocShell* mpDocSh; + const EditTextObject* mpEditObj; + sal_Bool mbHeader; + sal_Bool mbDataValid; + SvxAdjust meAdjust; +}; + +class ScAccessibleNoteTextData : public ScAccessibleTextData +{ +public: + ScAccessibleNoteTextData(ScPreviewShell* pViewShell, + const String& sText, const ScAddress& aCellPos, sal_Bool bMarkNote); + virtual ~ScAccessibleNoteTextData(); + + virtual ScAccessibleTextData* Clone() const; + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + + virtual SvxTextForwarder* GetTextForwarder(); + virtual SvxViewForwarder* GetViewForwarder(); + virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate ) { return NULL; } + + virtual void UpdateData() { } + virtual void SetDoUpdate(sal_Bool bValue) { } + virtual sal_Bool IsDirty() const { return sal_False; } +private: + ScPreviewViewForwarder* mpViewForwarder; + ScPreviewShell* mpViewShell; + ScEditEngineDefaulter* mpEditEngine; + SvxEditEngineForwarder* mpForwarder; + ScDocShell* mpDocSh; + String msText; + ScAddress maCellPos; + sal_Bool mbMarkNote; + sal_Bool mbDataValid; +}; + #endif |