diff options
Diffstat (limited to 'sd/source/ui/slidesorter/view/SlsViewOverlay.cxx')
-rw-r--r-- | sd/source/ui/slidesorter/view/SlsViewOverlay.cxx | 261 |
1 files changed, 80 insertions, 181 deletions
diff --git a/sd/source/ui/slidesorter/view/SlsViewOverlay.cxx b/sd/source/ui/slidesorter/view/SlsViewOverlay.cxx index c1f5c984d3bc..5e338480e236 100644 --- a/sd/source/ui/slidesorter/view/SlsViewOverlay.cxx +++ b/sd/source/ui/slidesorter/view/SlsViewOverlay.cxx @@ -60,6 +60,9 @@ #include <svx/sdrpagewindow.hxx> #include <vcl/svapp.hxx> +#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> + using namespace ::sdr::overlay; namespace { @@ -170,64 +173,6 @@ OverlayBase::~OverlayBase (void) -void OverlayBase::Paint (void) -{ -} - - - - -bool OverlayBase::IsShowing (void) -{ - return isVisible(); -} - - - - -void OverlayBase::Toggle (void) -{ - if (IsShowing()) - Hide(); - else - Show(); -} - - - - -void OverlayBase::Show (void) -{ - setVisible(true); -} - - - - -void OverlayBase::Hide (void) -{ - setVisible(false); -} - - - - -ViewOverlay& OverlayBase::GetViewOverlay (void) -{ - return mrViewOverlay; -} - - - - -void OverlayBase::transform (const basegfx::B2DHomMatrix& rMatrix) -{ - (void)rMatrix; -} - - - - void OverlayBase::EnsureRegistration (void) { if (getOverlayManager() == NULL) @@ -246,7 +191,6 @@ void OverlayBase::EnsureRegistration (void) SubstitutionOverlay::SubstitutionOverlay (ViewOverlay& rViewOverlay) : OverlayBase(rViewOverlay), maPosition(0,0), - maBoundingBox(), maShapes() { } @@ -268,17 +212,20 @@ void SubstitutionOverlay::Create ( EnsureRegistration(); maPosition = rPosition; - maTranslation = Point(0,0); maShapes.clear(); while (rSelection.HasMoreElements()) { const Rectangle aBox (rSelection.GetNextElement()->GetPageObject()->GetCurrentBoundRect()); - maShapes.push_back(aBox); - maBoundingBox.Union(aBox); + basegfx::B2DRectangle aB2DBox( + aBox.Left(), + aBox.Top(), + aBox.Right(), + aBox.Bottom()); + maShapes.append(basegfx::tools::createPolygonFromRect(aB2DBox), 4); } - setVisible(maShapes.size() > 0); + setVisible(maShapes.count() > 0); // The selection indicator may have been visible already so call // objectChange() to enforce an update. objectChange(); @@ -290,7 +237,6 @@ void SubstitutionOverlay::Create ( void SubstitutionOverlay::Clear (void) { maShapes.clear(); - maBoundingBox.SetEmpty(); setVisible(false); } @@ -299,9 +245,10 @@ void SubstitutionOverlay::Clear (void) void SubstitutionOverlay::Move (const Point& rOffset) { - maTranslation += rOffset; - maBoundingBox.Move(rOffset.X(), rOffset.Y()); + basegfx::B2DHomMatrix aTranslation; + aTranslation.translate(rOffset.X(), rOffset.Y()); + maShapes.transform(aTranslation); maPosition += rOffset; objectChange(); @@ -312,70 +259,52 @@ void SubstitutionOverlay::Move (const Point& rOffset) void SubstitutionOverlay::SetPosition (const Point& rPosition) { - Move(rPosition - maPosition); + Move(rPosition - GetPosition()); } -void SubstitutionOverlay::drawGeometry (OutputDevice& rOutputDevice) +Point SubstitutionOverlay::GetPosition (void) const { - if (getOverlayManager() != NULL) - { - const sal_uInt32 nSavedStripeLength (getOverlayManager()->getStripeLengthPixel()); - - for (::std::vector<Rectangle>::const_iterator - iBox (maShapes.begin()), - iEnd (maShapes.end()); - iBox!=iEnd; - ++iBox) - { - // Reduce width and height by one pixel to make the box the same - // size as the frame of the page object. - Rectangle aScreenBox (rOutputDevice.LogicToPixel(*iBox)); - aScreenBox.Right() -= 1; - aScreenBox.Bottom() -= 1; - - // Add accumulated translation. - Rectangle aBox (rOutputDevice.PixelToLogic(aScreenBox)); - aBox.Move(maTranslation.X(), maTranslation.Y()); - - ImpDrawPolygonStriped(rOutputDevice, - basegfx::tools::createPolygonFromRect( - basegfx::B2DRange( - basegfx::B2IRange(aBox.Left(), aBox.Top(), aBox.Right(),aBox.Bottom())))); - } - - getOverlayManager()->setStripeLengthPixel(nSavedStripeLength); - } + return maPosition; } -void SubstitutionOverlay::createBaseRange (OutputDevice& rOutputDevice) +drawinglayer::primitive2d::Primitive2DSequence SubstitutionOverlay::createOverlayObjectPrimitive2DSequence() { - (void)rOutputDevice; - - maBaseRange = basegfx::B2DRange( - basegfx::B2IRange( - maBoundingBox.Left(), - maBoundingBox.Top(), - maBoundingBox.Right(), - maBoundingBox.Bottom())); -} + drawinglayer::primitive2d::Primitive2DSequence aRetval; + const sal_uInt32 nCount(maShapes.count()); + if(nCount && getOverlayManager()) + { + aRetval.realloc(nCount); + const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor()); + const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor()); + for(sal_uInt32 a(0); a < nCount; a++) + { + aRetval[a] = drawinglayer::primitive2d::Primitive2DReference( + new drawinglayer::primitive2d::PolygonMarkerPrimitive2D( + maShapes.getB2DPolygon(a), + aRGBColorA, + aRGBColorB, + gnSubstitutionStripeLength)); + } + } + return aRetval; +} -Point SubstitutionOverlay::GetPosition (void) const +void SubstitutionOverlay::stripeDefinitionHasChanged() { - return maPosition; + // react on OverlayManager's stripe definition change + objectChange(); } - - //===== SelectionRectangleOverlay =========================================== SelectionRectangleOverlay::SelectionRectangleOverlay (ViewOverlay& rViewOverlay) @@ -418,28 +347,33 @@ void SelectionRectangleOverlay::Update (const Point& rSecondCorner) -void SelectionRectangleOverlay::drawGeometry (OutputDevice& rOutputDevice) +drawinglayer::primitive2d::Primitive2DSequence SelectionRectangleOverlay::createOverlayObjectPrimitive2DSequence() { - ImpDrawRangeStriped( - rOutputDevice, - basegfx::B2DRange( - maAnchor.X(), - maAnchor.Y(), - maSecondCorner.X(), - maSecondCorner.Y())); -} - + drawinglayer::primitive2d::Primitive2DSequence aRetval; + const basegfx::B2DRange aRange(maAnchor.X(), maAnchor.Y(), maSecondCorner.X(), maSecondCorner.Y()); + const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(aRange)); + if(aPolygon.count()) + { + const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor()); + const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor()); + const drawinglayer::primitive2d::Primitive2DReference xReference( + new drawinglayer::primitive2d::PolygonMarkerPrimitive2D( + aPolygon, + aRGBColorA, + aRGBColorB, + gnSubstitutionStripeLength)); + + aRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); + } + return aRetval; +} -void SelectionRectangleOverlay::createBaseRange (OutputDevice& rOutputDevice) +void SelectionRectangleOverlay::stripeDefinitionHasChanged() { - (void)rOutputDevice; - maBaseRange = basegfx::B2DRange( - maAnchor.X(), - maAnchor.Y(), - maSecondCorner.X(), - maSecondCorner.Y()); + // react on OverlayManager's stripe definition change + objectChange(); } @@ -540,40 +474,23 @@ sal_Int32 InsertionIndicatorOverlay::GetInsertionPageIndex (void) const -void InsertionIndicatorOverlay::drawGeometry (OutputDevice& rOutputDevice) +drawinglayer::primitive2d::Primitive2DSequence InsertionIndicatorOverlay::createOverlayObjectPrimitive2DSequence() { - const Color aFillColor (rOutputDevice.GetFillColor()); - const Color aLineColor (rOutputDevice.GetLineColor()); - - if (isVisible()) - { - const Color aColor (rOutputDevice.GetSettings().GetStyleSettings().GetFontColor()); - rOutputDevice.SetLineColor(aColor); - rOutputDevice.SetFillColor(aColor); - - // Reduce width of indicator by one pixel to be of the same width as - // the page objects. - Rectangle aBox (rOutputDevice.LogicToPixel(maBoundingBox)); - aBox.Right() -= 1; - rOutputDevice.DrawRect(rOutputDevice.PixelToLogic(aBox)); - } - - rOutputDevice.SetFillColor(aFillColor); - rOutputDevice.SetLineColor(aLineColor); -} - + drawinglayer::primitive2d::Primitive2DSequence aRetval(2); + const basegfx::B2DRange aRange(maBoundingBox.Left(), maBoundingBox.Top(), maBoundingBox.Right(), maBoundingBox.Bottom()); + const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(aRange)); + const basegfx::BColor aRGBColor(Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetFontColor().getBColor()); + aRetval[0] = drawinglayer::primitive2d::Primitive2DReference( + new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( + basegfx::B2DPolyPolygon(aPolygon), + aRGBColor)); + aRetval[1] = drawinglayer::primitive2d::Primitive2DReference( + new drawinglayer::primitive2d::PolygonHairlinePrimitive2D( + aPolygon, + aRGBColor)); - -void InsertionIndicatorOverlay::createBaseRange (OutputDevice& rOutputDevice) -{ - (void)rOutputDevice; - const sal_Int32 nBorder (10); - maBaseRange = basegfx::B2DRange( - maBoundingBox.Left()-nBorder, - maBoundingBox.Top()-nBorder, - maBoundingBox.Right()-nBorder, - maBoundingBox.Bottom()-nBorder); + return aRetval; } @@ -634,34 +551,16 @@ void MouseOverIndicatorOverlay::SetSlideUnderMouse ( -void MouseOverIndicatorOverlay::drawGeometry (OutputDevice& rOutputDevice) +drawinglayer::primitive2d::Primitive2DSequence MouseOverIndicatorOverlay::createOverlayObjectPrimitive2DSequence() { - const Color aFillColor (rOutputDevice.GetFillColor()); - const Color aLineColor (rOutputDevice.GetLineColor()); - view::PageObjectViewObjectContact* pContact = GetViewObjectContact(); - if (pContact != NULL) - pContact->PaintMouseOverEffect(rOutputDevice, true); - - rOutputDevice.SetFillColor(aFillColor); - rOutputDevice.SetLineColor(aLineColor); -} - - - -void MouseOverIndicatorOverlay::createBaseRange (OutputDevice& rOutputDevice) -{ - (void)rOutputDevice; - view::PageObjectViewObjectContact* pContact = GetViewObjectContact(); - if (pContact != NULL) + if(pContact) { - Rectangle aBox (pContact->GetBoundingBox( - rOutputDevice, - view::PageObjectViewObjectContact::MouseOverIndicatorBoundingBox, - view::PageObjectViewObjectContact::ModelCoordinateSystem)); - maBaseRange = basegfx::B2DRange(aBox.Left(),aBox.Top(),aBox.Right(),aBox.Bottom()); + return pContact->createMouseOverEffectPrimitive2DSequence(); } + + return drawinglayer::primitive2d::Primitive2DSequence(); } |