diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2009-09-18 15:39:21 +0000 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2009-09-18 15:39:21 +0000 |
commit | 108632dc97a720639df495de3b5d966ee286be95 (patch) | |
tree | 99de8dfff36b6296f135f3288fa400a884ec081c /sdext/source/presenter/PresenterNotesView.cxx | |
parent | ef43d23e180d94f8a060388460c988d6d4126c6b (diff) |
CWS-TOOLING: integrate CWS impressaccessibility3
2009-09-18 16:10:59 +0200 af r276289 : #i102525# Fixed some minor compilation problems.
2009-09-17 14:11:23 +0200 af r276243 : #i102525# Fixed F1 shortcut for help view.
2009-09-16 16:20:58 +0200 af r276205 : #i102525# Removing const to make Solaris linker happy.
2009-09-16 16:13:25 +0200 af r276204 : #i90690# Initializing variable to avoid compilation problem.
2009-09-15 19:10:04 +0200 af r276186 : #i90825# Replace edit source proxy when an outliner object is set.
2009-09-15 11:12:07 +0200 af r276160 : #i90690# Broadcast accessibility events when the current slide is changed.
2009-09-15 09:37:48 +0200 af r276148 : #i102525# Fixed Solaris compilation problem.
2009-09-14 18:12:40 +0200 af r276142 : #i102525# Added missing implementation for some font related functions.
2009-09-14 18:02:05 +0200 af r276139 : #i102525# Added accessibility support.
2009-09-14 17:30:13 +0200 af r276136 : #i102525# Added support for interface XPane2 to panes.
2009-09-14 17:00:27 +0200 af r276133 : #i102525# Added XPane2 interface.
2009-09-14 16:13:04 +0200 af r276131 : #i50376# Make the focus indicator visible when the slide sorter has the focus.
Diffstat (limited to 'sdext/source/presenter/PresenterNotesView.cxx')
-rw-r--r-- | sdext/source/presenter/PresenterNotesView.cxx | 517 |
1 files changed, 60 insertions, 457 deletions
diff --git a/sdext/source/presenter/PresenterNotesView.cxx b/sdext/source/presenter/PresenterNotesView.cxx index fce82f93faee..4a90b76247a1 100644 --- a/sdext/source/presenter/PresenterNotesView.cxx +++ b/sdext/source/presenter/PresenterNotesView.cxx @@ -38,7 +38,10 @@ #include "PresenterGeometryHelper.hxx" #include "PresenterPaintManager.hxx" #include "PresenterScrollBar.hxx" +#include "PresenterTextView.hxx" +#include <com/sun/star/accessibility/AccessibleTextType.hpp> #include <com/sun/star/awt/Key.hpp> +#include <com/sun/star/awt/KeyModifier.hpp> #include <com/sun/star/awt/PosSize.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/drawing/framework/XControllerManager.hpp> @@ -71,93 +74,6 @@ static const double gnLineScrollFactor (1.2); namespace sdext { namespace presenter { -//===== PresenterNotesView::BitmapContainer =================================== - -namespace { - class NotesBitmapDescriptor - { - public: - NotesBitmapDescriptor (const sal_Int32 nTop, const sal_Int32 nBottom, - const Reference<rendering::XBitmap> xBitmap) - : Top(nTop), Bottom(nBottom), Bitmap(xBitmap) - { } - sal_Int32 Top; - sal_Int32 Bottom; - Reference<rendering::XBitmap> Bitmap; - }; - typedef ::boost::shared_ptr<NotesBitmapDescriptor> SharedNotesBitmapDescriptor; -} -typedef ::std::vector<SharedNotesBitmapDescriptor> BitmapDescriptorSet; - - -/** Container of bitmaps that show parts of the notes text. If the bitmaps - use more than a specified amount of memory then some bitmaps that are - currently not on the screen are discarded. -*/ -class PresenterNotesView::BitmapContainer - : public BitmapDescriptorSet -{ -public: - BitmapContainer (const ::boost::shared_ptr<BitmapFactory>& rpFactory); - - /** Call this when for instance the font size has changed and all - bitmaps have to be created anew or the slide has changed. - */ - void Clear (void); - void Prune (const sal_Int32 nTop, const sal_Int32 nBottom); - sal_Int32 GetMemorySize (const Reference<rendering::XBitmap>& rxBitmap) const; - sal_Int32 GetMemorySize (void) const; - const_iterator GetBegin (const double nTop, const double nBottom); - const_iterator GetEnd (const double nTop, const double nBottom); - -private: - ::boost::shared_ptr<BitmapFactory> mpFactory; - sal_Int32 mnMaximalCacheSize; - const sal_Int32 mnPartHeight; - sal_Int32 mnTotalHeight; - - sal_Int32 GetTopIndex (const double nValue) const; - sal_Int32 GetBottomIndex (const double nValue) const; - void ProvideBitmaps ( - const sal_Int32 nTopIndex, - const sal_Int32 nBottomIndex); -}; - - - - -//===== PresenterNotesView::BitmapFactory ===================================== - -class PresenterNotesView::BitmapFactory -{ -public: - BitmapFactory ( - const Reference<XComponentContext>& rxComponentContext, - const PresenterTheme::SharedFontDescriptor& rpFont, - const Reference<rendering::XCanvas>& rxCanvas, - const SharedBitmapDescriptor& rpBackground); - ~BitmapFactory (void); - void SetText (const OUString& rsText); - void SetWidth (const sal_Int32 nWidth); - void SetFontHeight (const sal_Int32 nHeight); - sal_Int32 GetHeightForWidth (const sal_Int32 nWidth); - sal_Int32 GetTotalHeight (void); - Reference<rendering::XBitmap> CreateBitmap (const sal_Int32 nTop, const sal_Int32 nBottom); - -private: - Reference<rendering::XCanvas> mxCanvas; - OUString msText; - PresenterTheme::SharedFontDescriptor mpFont; - css::awt::FontDescriptor maFontDescriptor; - sal_Int32 mnWidth; - sal_Int32 mnTotalHeight; - css::uno::Reference<css::beans::XPropertySet> mxTextView; - SharedBitmapDescriptor mpBackground; -}; - - - - //===== PresenterNotesView ==================================================== PresenterNotesView::PresenterNotesView ( @@ -169,8 +85,6 @@ PresenterNotesView::PresenterNotesView ( mxViewId(rxViewId), mpPresenterController(rpPresenterController), mxCanvas(), - mpBitmapContainer(), - mpBitmapFactory(), mxCurrentNotesPage(), mpScrollBar(), mxToolBarWindow(), @@ -182,7 +96,8 @@ PresenterNotesView::PresenterNotesView ( maTextBoundingBox(), mpBackground(), mnTop(0), - mnFontSize(12) + mpFont(), + mpTextView() { try { @@ -192,19 +107,16 @@ PresenterNotesView::PresenterNotesView ( mxParentWindow = xPane->getWindow(); mxCanvas = xPane->getCanvas(); - - const OUString sResourceURL (mxViewId->getResourceURL()); - PresenterTheme::SharedFontDescriptor pFont( - rpPresenterController->GetViewFont(sResourceURL)); - mpBitmapFactory.reset(new BitmapFactory( + mpTextView.reset(new PresenterTextView( rxComponentContext, - pFont, mxCanvas, - mpPresenterController->GetViewBackground(mxViewId->getResourceURL()))); - mpBitmapContainer.reset(new BitmapContainer(mpBitmapFactory)); + mpPresenterController->GetPaintManager()->GetInvalidator(mxParentWindow))); - maSeparatorColor = pFont->mnColor; - mnFontSize = pFont->mnSize; + const OUString sResourceURL (mxViewId->getResourceURL()); + mpFont.reset(new PresenterTheme::FontDescriptor( + rpPresenterController->GetViewFont(sResourceURL))); + maSeparatorColor = mpFont->mnColor; + mpTextView->SetFont(mpFont); CreateToolBar(rxComponentContext, rpPresenterController); @@ -383,16 +295,14 @@ void PresenterNotesView::SetSlide (const Reference<drawing::XDrawPage>& rxNotesP if (xText.is()) { sText += xText->getString(); + mpTextView->SetText(Reference<text::XText>(xText, UNO_QUERY)); } } } } } - mpBitmapFactory->SetText(sText); - Layout(); - mpBitmapContainer->Clear(); if (mpScrollBar.get() != NULL) { @@ -535,12 +445,12 @@ void SAL_CALL PresenterNotesView::keyPressed (const awt::KeyEvent& rEvent) switch (rEvent.KeyCode) { case awt::Key::A: - Scroll(-gnLineScrollFactor * mnFontSize); + Scroll(-gnLineScrollFactor * mpFont->mnSize); break; case awt::Key::Y: case awt::Key::Z: - Scroll(+gnLineScrollFactor * mnFontSize); + Scroll(+gnLineScrollFactor * mpFont->mnSize); break; case awt::Key::S: @@ -550,6 +460,24 @@ void SAL_CALL PresenterNotesView::keyPressed (const awt::KeyEvent& rEvent) case awt::Key::G: ChangeFontSize(+1); break; + + case awt::Key::H: + if (mpTextView) + mpTextView->MoveCaret( + -1, + (rEvent.Modifiers == awt::KeyModifier::SHIFT) + ? cssa::AccessibleTextType::CHARACTER + : cssa::AccessibleTextType::WORD); + break; + + case awt::Key::L: + if (mpTextView) + mpTextView->MoveCaret( + +1, + (rEvent.Modifiers == awt::KeyModifier::SHIFT) + ? cssa::AccessibleTextType::CHARACTER + : cssa::AccessibleTextType::WORD); + break; } } @@ -602,8 +530,7 @@ void PresenterNotesView::Layout (void) try { const double nTextBoxHeight (aNewTextBoundingBox.Y2 - aNewTextBoundingBox.Y1); - const sal_Int32 nHeight (mpBitmapFactory->GetHeightForWidth( - sal_Int32(aNewTextBoundingBox.X2 - aNewTextBoundingBox.X1))); + const double nHeight (mpTextView->GetTotalTextHeight()); if (nHeight > nTextBoxHeight) { bShowVerticalScrollbar = true; @@ -617,7 +544,6 @@ void PresenterNotesView::Layout (void) } mpScrollBar->SetVisible(bShowVerticalScrollbar); - mpBitmapFactory->SetWidth(sal_Int32(aNewTextBoundingBox.X2 - aNewTextBoundingBox.X1)); mpScrollBar->SetPosSize( geometry::RealRectangle2D( aNewTextBoundingBox.X2, @@ -638,14 +564,14 @@ void PresenterNotesView::Layout (void) { maTextBoundingBox = aNewTextBoundingBox; - // When the size has changed then we need a new text bitmap. - if (aNewTextBoundingBox.X2-aNewTextBoundingBox.X1 - != maTextBoundingBox.X2-maTextBoundingBox.X1 - || aNewTextBoundingBox.Y2-aNewTextBoundingBox.Y1 - != maTextBoundingBox.Y2-maTextBoundingBox.Y1) - { - mpBitmapContainer->Clear(); - } + mpTextView->SetLocation( + geometry::RealPoint2D( + aNewTextBoundingBox.X1, + aNewTextBoundingBox.Y1)); + mpTextView->SetSize( + geometry::RealSize2D( + aNewTextBoundingBox.X2 - aNewTextBoundingBox.X1, + aNewTextBoundingBox.Y2 - aNewTextBoundingBox.Y1)); } } @@ -668,6 +594,8 @@ void PresenterNotesView::Paint (const awt::Rectangle& rUpdateBox) PaintText(rUpdateBox); } + mpTextView->Paint(rUpdateBox); + if (rUpdateBox.Y + rUpdateBox.Height > maTextBoundingBox.Y2) { PaintToolBar(rUpdateBox); @@ -743,21 +671,6 @@ void PresenterNotesView::PaintText (const awt::Rectangle& rUpdateBox) awt::Rectangle()); } - // Iterator over all bitmaps that are (partially) visible and paint - // them. - const double nBottom (mnTop + maTextBoundingBox.Y2 - maTextBoundingBox.Y1); - BitmapContainer::const_iterator iBitmap (mpBitmapContainer->GetBegin(mnTop, nBottom)); - BitmapContainer::const_iterator iEnd (mpBitmapContainer->GetEnd(mnTop, nBottom)); - for ( ; iBitmap!=iEnd; ++iBitmap) - { - if (iBitmap->get() != NULL && (*iBitmap)->Bitmap.is()) - { - aRenderState.AffineTransform.m02 = maTextBoundingBox.X1; - aRenderState.AffineTransform.m12 = (*iBitmap)->Top + maTextBoundingBox.Y1 - mnTop; - mxCanvas->drawBitmap((*iBitmap)->Bitmap, aViewState, aRenderState); - } - } - Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY); if (xSpriteCanvas.is()) xSpriteCanvas->updateScreen(sal_False); @@ -781,6 +694,7 @@ void PresenterNotesView::Scroll (const double rnDistance) try { mnTop += rnDistance; + mpTextView->SetOffset(0, mnTop); UpdateScrollBar(); Invalidate(); @@ -797,6 +711,7 @@ void PresenterNotesView::SetTop (const double nTop) try { mnTop = nTop; + mpTextView->SetOffset(0, mnTop); UpdateScrollBar(); Invalidate(); @@ -810,12 +725,12 @@ void PresenterNotesView::SetTop (const double nTop) void PresenterNotesView::ChangeFontSize (const sal_Int32 nSizeChange) { - const sal_Int32 nNewSize (mnFontSize + nSizeChange); + const sal_Int32 nNewSize (mpFont->mnSize + nSizeChange); if (nNewSize > 5) { - mnFontSize = nNewSize; - mpBitmapFactory->SetFontHeight(mnFontSize); - mpBitmapContainer->Clear(); + mpFont->mnSize = nNewSize; + mpFont->mxFont = NULL; + mpTextView->SetFont(mpFont); Layout(); UpdateScrollBar(); @@ -847,21 +762,28 @@ void PresenterNotesView::ChangeFontSize (const sal_Int32 nSizeChange) +::boost::shared_ptr<PresenterTextView> PresenterNotesView::GetTextView (void) const +{ + return mpTextView; +} + + + + void PresenterNotesView::UpdateScrollBar (void) { if (mpScrollBar.get() != NULL) { try { - double nHeight = mpBitmapFactory->GetTotalHeight(); - mpScrollBar->SetTotalSize(nHeight); + mpScrollBar->SetTotalSize(mpTextView->GetTotalTextHeight()); } catch(beans::UnknownPropertyException&) { OSL_ASSERT(false); } - mpScrollBar->SetLineHeight(mnFontSize*1.2); + mpScrollBar->SetLineHeight(mpFont->mnSize*1.2); mpScrollBar->SetThumbPosition(mnTop, false); mpScrollBar->SetThumbSize(maTextBoundingBox.Y2 - maTextBoundingBox.Y1); @@ -886,323 +808,4 @@ void PresenterNotesView::ThrowIfDisposed (void) -//===== PresenterNotesView::BitmapContainer =================================== - -PresenterNotesView::BitmapContainer::BitmapContainer ( - const ::boost::shared_ptr<BitmapFactory>& rpFactory) - : mpFactory(rpFactory), - mnMaximalCacheSize(gnMaximalCacheSize), - mnPartHeight(gnPartHeight), - mnTotalHeight(0) -{ -} - - - - -void PresenterNotesView::BitmapContainer::Clear (void) -{ - clear(); - mnTotalHeight = mpFactory->GetTotalHeight(); - const sal_Int32 nSize ((mnTotalHeight+mnPartHeight-1) / mnPartHeight); - if (nSize > 0) - resize(nSize, SharedNotesBitmapDescriptor()); -} - - - - -void PresenterNotesView::BitmapContainer::Prune ( - const sal_Int32 nTopIndex, - const sal_Int32 nBottomIndex) -{ - sal_Int32 nDistance (::std::max(nTopIndex-0, sal_Int32(size())-nBottomIndex)); - sal_Int32 nIndex; - sal_Int32 nTotalSize (GetMemorySize()); - iterator iPart; - - while (nDistance > 0 - && nTotalSize > mnMaximalCacheSize) - { - // Remove bitmap that is nDistance places before nTopIndex. - nIndex = nTopIndex - nDistance; - if (nIndex >= 0) - { - iPart = begin() + nIndex; - nTotalSize -= GetMemorySize((*iPart)->Bitmap); - (*iPart)->Bitmap = NULL; - } - - if (nTotalSize <= mnMaximalCacheSize) - break; - - // Remove bitmap that is nDistance places behind nBottomIndex. - nIndex = nBottomIndex + nDistance; - if (nIndex < sal_Int32(size())) - { - iPart = begin() + nIndex; - nTotalSize -= GetMemorySize((*iPart)->Bitmap); - (*iPart)->Bitmap = NULL; - } - } -} - - - - -sal_Int32 PresenterNotesView::BitmapContainer::GetMemorySize ( - const Reference<rendering::XBitmap>& rxBitmap) const -{ - if (rxBitmap.is()) - { - const geometry::IntegerSize2D aSize (rxBitmap->getSize()); - return aSize.Width * aSize.Height * 3; - } - return 0; -} - - - - -sal_Int32 PresenterNotesView::BitmapContainer::GetMemorySize (void) const -{ - sal_Int32 nSize (0); - for (const_iterator iBitmap=begin(); iBitmap!=end(); ++iBitmap) - if (iBitmap->get() != NULL) - if ((*iBitmap)->Bitmap.is()) - nSize += GetMemorySize((*iBitmap)->Bitmap); - return nSize; -} - - - - -sal_Int32 PresenterNotesView::BitmapContainer::GetTopIndex (const double nValue) const -{ - const sal_Int32 nIndex (sal::static_int_cast<sal_Int32>(nValue) / mnPartHeight); - if (nIndex < 0) - return 0; - else if (nIndex >= sal_Int32(size())) - return sal_Int32(size())-1; - else - return nIndex; -} - - - - -sal_Int32 PresenterNotesView::BitmapContainer::GetBottomIndex (const double nValue) const -{ - const sal_Int32 nIndex ((sal::static_int_cast<sal_Int32>(nValue)+mnPartHeight-1) / mnPartHeight); - if (nIndex >= sal_Int32(size())) - return size()-1; - else if (nIndex < 0) - return -1; - else return nIndex; -} - - - - -PresenterNotesView::BitmapContainer::const_iterator PresenterNotesView::BitmapContainer::GetBegin ( - const double nTop, - const double nBottom) -{ - const sal_Int32 nTopIndex (GetTopIndex(nTop)); - const sal_Int32 nBottomIndex(GetBottomIndex(nBottom)); - ProvideBitmaps(nTopIndex, nBottomIndex); - if (nTopIndex >= 0) - return begin()+nTopIndex; - else - return end(); -} - - - - -PresenterNotesView::BitmapContainer::const_iterator PresenterNotesView::BitmapContainer::GetEnd ( - const double nTop, - const double nBottom) -{ - (void)nTop; - const sal_Int32 nIndex (GetBottomIndex(nBottom)); - if (nIndex >= 0) - return (begin() + nIndex)+1; - else - return end(); -} - - - - -void PresenterNotesView::BitmapContainer::ProvideBitmaps ( - const sal_Int32 nTopIndex, - const sal_Int32 nBottomIndex) -{ - BitmapDescriptorSet aNewBitmaps; - - if (nTopIndex < 0 || nBottomIndex<0) - return; - - if (nTopIndex > nBottomIndex) - return; - - for (sal_Int32 nIndex=nTopIndex; nIndex<=nBottomIndex; ++nIndex) - { - iterator iPart (begin() + nIndex); - const sal_Int32 nTop (nIndex * mnPartHeight); - const sal_Int32 nBottom (nTop + mnPartHeight - 1); - if (iPart->get() == NULL) - { - iPart->reset(new NotesBitmapDescriptor(nTop, nBottom, NULL)); - } - if ( ! (*iPart)->Bitmap.is()) - { - (*iPart)->Bitmap = mpFactory->CreateBitmap(nTop, nBottom); - (*iPart)->Top = nTop; - (*iPart)->Bottom = nTop + (*iPart)->Bitmap->getSize().Height; - } - } - - // Calculate memory size used by all bitmaps. - if (GetMemorySize() > mnMaximalCacheSize) - Prune(nTopIndex,nBottomIndex); -} - - - - -//===== PresenterNotesView::BitmapFactory ===================================== - -PresenterNotesView::BitmapFactory::BitmapFactory ( - const Reference<XComponentContext>& rxComponentContext, - const PresenterTheme::SharedFontDescriptor& rpFont, - const Reference<rendering::XCanvas>& rxCanvas, - const SharedBitmapDescriptor& rpBackground) - : mxCanvas(rxCanvas), - msText(), - mpFont(rpFont), - maFontDescriptor(), - mnWidth(100), - mnTotalHeight(0), - mxTextView(), - mpBackground(rpBackground) -{ - Reference<lang::XMultiComponentFactory> xFactory ( - rxComponentContext->getServiceManager(), UNO_QUERY_THROW); - Sequence<Any> aArguments(1); - aArguments[0] <<= rxCanvas; - mxTextView = Reference<beans::XPropertySet>( - xFactory->createInstanceWithArgumentsAndContext( - A2S("com.sun.star.drawing.PresenterTextView"), - aArguments, - rxComponentContext), - UNO_QUERY_THROW); - mxTextView->setPropertyValue(A2S("BackgroundColor"), Any(sal_uInt32(0x00ff0000))); - if (mpFont.get() != NULL) - { - maFontDescriptor.Name = mpFont->msFamilyName; - maFontDescriptor.Height = sal::static_int_cast<sal_Int16>(mpFont->mnSize); - maFontDescriptor.StyleName = mpFont->msStyleName; - mxTextView->setPropertyValue(A2S("FontDescriptor"), Any(maFontDescriptor)); - mxTextView->setPropertyValue(A2S("TextColor"), Any(mpFont->mnColor)); - } -} - - - - -PresenterNotesView::BitmapFactory::~BitmapFactory (void) -{ - { - Reference<XComponent> xComponent (mxTextView, UNO_QUERY); - mxTextView = NULL; - if (xComponent.is()) - xComponent->dispose(); - } -} - - - - -void PresenterNotesView::BitmapFactory::SetText (const OUString& rsText) -{ - if (mxTextView.is()) - mxTextView->setPropertyValue(A2S("Text"), Any(rsText)); - mnTotalHeight = 0; -} - - - - -void PresenterNotesView::BitmapFactory::SetWidth (const sal_Int32 nWidth) -{ - mnWidth = nWidth; -} - - - - -void PresenterNotesView::BitmapFactory::SetFontHeight (const sal_Int32 nHeight) -{ - maFontDescriptor.Height = sal::static_int_cast<sal_Int16>(nHeight); - mxTextView->setPropertyValue(A2S("FontDescriptor"), Any(maFontDescriptor)); - if (mpFont.get() != NULL) - mpFont->mnSize = nHeight; - mnTotalHeight = 0; -} - - - - -sal_Int32 PresenterNotesView::BitmapFactory::GetHeightForWidth (const sal_Int32 nWidth) -{ - mxTextView->setPropertyValue( - A2S("Size"), - Any(awt::Size(nWidth, 100))); - sal_Int32 nHeight (0); - if (mxTextView->getPropertyValue(A2S("TotalHeight")) >>= nHeight) - return nHeight; - else - return -1; -} - - - - -sal_Int32 PresenterNotesView::BitmapFactory::GetTotalHeight (void) -{ - if (mnTotalHeight == 0) - { - sal_Int32 nHeight (0); - if (mxTextView->getPropertyValue(A2S("TotalHeight")) >>= nHeight) - mnTotalHeight = nHeight; - } - return mnTotalHeight; -} - - - - -Reference<rendering::XBitmap> PresenterNotesView::BitmapFactory::CreateBitmap ( - const sal_Int32 nTop, - const sal_Int32 nBottom) -{ - // Get text bitmap. - sal_Int32 nHeight; - if (nBottom > GetTotalHeight()) - nHeight = GetTotalHeight() - nTop + 1; - else - nHeight = nBottom - nTop + 1; - mxTextView->setPropertyValue(A2S("Size"), Any(awt::Size(mnWidth,nHeight))); - mxTextView->setPropertyValue(A2S("Top"), Any(sal_Int32(nTop))); - Reference<rendering::XBitmap> xTextBitmap ( - mxTextView->getPropertyValue(A2S("Bitmap")), UNO_QUERY); - - return xTextBitmap; -} - - - - } } // end of namespace ::sdext::presenter |