diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-11-08 22:11:33 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-11-08 22:17:48 -0500 |
commit | 9229170920ab770624415c4330da57af5b1b5398 (patch) | |
tree | f919af4ad0ca25a297b2aae6518c13280f5ad50e /svx | |
parent | a305869e99a73626534a921c36eb352cd74582a5 (diff) |
Unindent.
Change-Id: I98b5a0b91c92e58bae3caa69a4ed35c72dc839dd
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/sdr/contact/objectcontactofobjlistpainter.cxx | 281 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewcontactofe3d.cxx | 270 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewcontactofe3dscene.cxx | 699 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewcontactofpageobj.cxx | 83 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx | 90 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewcontactofsdrrectobj.cxx | 109 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewcontactoftextobj.cxx | 25 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewcontactofvirtobj.cxx | 141 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewobjectcontactofpageobj.cxx | 544 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewobjectcontactredirector.cxx | 34 |
10 files changed, 1095 insertions, 1181 deletions
diff --git a/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx b/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx index eadd8a77dbef..63cfbd507041 100644 --- a/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx +++ b/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx @@ -29,186 +29,167 @@ #include <svx/unoapi.hxx> #include <boost/scoped_ptr.hpp> +namespace sdr { namespace contact { -namespace sdr +ObjectContactPainter::ObjectContactPainter() { - namespace contact - { - ObjectContactPainter::ObjectContactPainter() - { - } +} - // The destructor. - ObjectContactPainter::~ObjectContactPainter() - { - } - } // end of namespace contact -} // end of namespace sdr +// The destructor. +ObjectContactPainter::~ObjectContactPainter() +{ +} + +sal_uInt32 ObjectContactOfObjListPainter::GetPaintObjectCount() const +{ + return maStartObjects.size(); +} +ViewContact& ObjectContactOfObjListPainter::GetPaintObjectViewContact(sal_uInt32 nIndex) const +{ + const SdrObject* pObj = maStartObjects[nIndex]; + DBG_ASSERT(pObj, "ObjectContactOfObjListPainter: Corrupt SdrObjectVector (!)"); + return pObj->GetViewContact(); +} + +ObjectContactOfObjListPainter::ObjectContactOfObjListPainter( + OutputDevice& rTargetDevice, + const SdrObjectVector& rObjects, + const SdrPage* pProcessedPage) +: ObjectContactPainter(), + mrTargetOutputDevice(rTargetDevice), + maStartObjects(rObjects), + mpProcessedPage(pProcessedPage) +{ +} +ObjectContactOfObjListPainter::~ObjectContactOfObjListPainter() +{ +} -namespace sdr +// Process the whole displaying +void ObjectContactOfObjListPainter::ProcessDisplay(DisplayInfo& rDisplayInfo) { - namespace contact + const sal_uInt32 nCount(GetPaintObjectCount()); + + if(nCount) { - sal_uInt32 ObjectContactOfObjListPainter::GetPaintObjectCount() const - { - return maStartObjects.size(); - } + OutputDevice* pTargetDevice = TryToGetOutputDevice(); - ViewContact& ObjectContactOfObjListPainter::GetPaintObjectViewContact(sal_uInt32 nIndex) const + if(pTargetDevice) { - const SdrObject* pObj = maStartObjects[nIndex]; - DBG_ASSERT(pObj, "ObjectContactOfObjListPainter: Corrupt SdrObjectVector (!)"); - return pObj->GetViewContact(); - } + // update current ViewInformation2D at the ObjectContact + const GDIMetaFile* pMetaFile = pTargetDevice->GetConnectMetaFile(); + const bool bOutputToRecordingMetaFile(pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause()); + basegfx::B2DRange aViewRange; - ObjectContactOfObjListPainter::ObjectContactOfObjListPainter( - OutputDevice& rTargetDevice, - const SdrObjectVector& rObjects, - const SdrPage* pProcessedPage) - : ObjectContactPainter(), - mrTargetOutputDevice(rTargetDevice), - maStartObjects(rObjects), - mpProcessedPage(pProcessedPage) - { - } + // create ViewRange + if(!bOutputToRecordingMetaFile) + { + // use visible pixels, but transform to world coordinates + const Size aOutputSizePixel(pTargetDevice->GetOutputSizePixel()); + aViewRange = ::basegfx::B2DRange(0.0, 0.0, aOutputSizePixel.getWidth(), aOutputSizePixel.getHeight()); + aViewRange.transform(pTargetDevice->GetInverseViewTransformation()); + } - ObjectContactOfObjListPainter::~ObjectContactOfObjListPainter() - { - } + // upate local ViewInformation2D + const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D( + basegfx::B2DHomMatrix(), + pTargetDevice->GetViewTransformation(), + aViewRange, + GetXDrawPageForSdrPage(const_cast< SdrPage* >(mpProcessedPage)), + 0.0, + com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>()); + updateViewInformation2D(aNewViewInformation2D); - // Process the whole displaying - void ObjectContactOfObjListPainter::ProcessDisplay(DisplayInfo& rDisplayInfo) - { - const sal_uInt32 nCount(GetPaintObjectCount()); + // collect primitive data in a sequence; this will already use the updated ViewInformation2D + drawinglayer::primitive2d::Primitive2DSequence xPrimitiveSequence; - if(nCount) + for(sal_uInt32 a(0L); a < nCount; a++) { - OutputDevice* pTargetDevice = TryToGetOutputDevice(); + const ViewObjectContact& rViewObjectContact = GetPaintObjectViewContact(a).GetViewObjectContact(*this); - if(pTargetDevice) - { - // update current ViewInformation2D at the ObjectContact - const GDIMetaFile* pMetaFile = pTargetDevice->GetConnectMetaFile(); - const bool bOutputToRecordingMetaFile(pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause()); - basegfx::B2DRange aViewRange; - - // create ViewRange - if(!bOutputToRecordingMetaFile) - { - // use visible pixels, but transform to world coordinates - const Size aOutputSizePixel(pTargetDevice->GetOutputSizePixel()); - aViewRange = ::basegfx::B2DRange(0.0, 0.0, aOutputSizePixel.getWidth(), aOutputSizePixel.getHeight()); - aViewRange.transform(pTargetDevice->GetInverseViewTransformation()); - } - - // upate local ViewInformation2D - const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D( - basegfx::B2DHomMatrix(), - pTargetDevice->GetViewTransformation(), - aViewRange, - GetXDrawPageForSdrPage(const_cast< SdrPage* >(mpProcessedPage)), - 0.0, - com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>()); - updateViewInformation2D(aNewViewInformation2D); - - // collect primitive data in a sequence; this will already use the updated ViewInformation2D - drawinglayer::primitive2d::Primitive2DSequence xPrimitiveSequence; - - for(sal_uInt32 a(0L); a < nCount; a++) - { - const ViewObjectContact& rViewObjectContact = GetPaintObjectViewContact(a).GetViewObjectContact(*this); - - drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xPrimitiveSequence, - rViewObjectContact.getPrimitive2DSequenceHierarchy(rDisplayInfo)); - } - - // if there is something to show, use a vclProcessor to render it - if(xPrimitiveSequence.hasElements()) - { - boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createProcessor2DFromOutputDevice( - *pTargetDevice, - getViewInformation2D())); - - if(pProcessor2D) - { - pProcessor2D->process(xPrimitiveSequence); - } - } - } + drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xPrimitiveSequence, + rViewObjectContact.getPrimitive2DSequenceHierarchy(rDisplayInfo)); } - } - // VirtualDevice? - bool ObjectContactOfObjListPainter::isOutputToVirtualDevice() const - { - return (OUTDEV_VIRDEV == mrTargetOutputDevice.GetOutDevType()); - } + // if there is something to show, use a vclProcessor to render it + if(xPrimitiveSequence.hasElements()) + { + boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createProcessor2DFromOutputDevice( + *pTargetDevice, + getViewInformation2D())); - // recording MetaFile? - bool ObjectContactOfObjListPainter::isOutputToRecordingMetaFile() const - { - GDIMetaFile* pMetaFile = mrTargetOutputDevice.GetConnectMetaFile(); - return (pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause()); + if(pProcessor2D) + { + pProcessor2D->process(xPrimitiveSequence); + } + } } + } +} - // pdf export? - bool ObjectContactOfObjListPainter::isOutputToPDFFile() const - { - return (0 != mrTargetOutputDevice.GetPDFWriter()); - } +// VirtualDevice? +bool ObjectContactOfObjListPainter::isOutputToVirtualDevice() const +{ + return (OUTDEV_VIRDEV == mrTargetOutputDevice.GetOutDevType()); +} - OutputDevice* ObjectContactOfObjListPainter::TryToGetOutputDevice() const - { - return &mrTargetOutputDevice; - } - } // end of namespace contact -} // end of namespace sdr +// recording MetaFile? +bool ObjectContactOfObjListPainter::isOutputToRecordingMetaFile() const +{ + GDIMetaFile* pMetaFile = mrTargetOutputDevice.GetConnectMetaFile(); + return (pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause()); +} +// pdf export? +bool ObjectContactOfObjListPainter::isOutputToPDFFile() const +{ + return (0 != mrTargetOutputDevice.GetPDFWriter()); +} +OutputDevice* ObjectContactOfObjListPainter::TryToGetOutputDevice() const +{ + return &mrTargetOutputDevice; +} -namespace sdr +sal_uInt32 ObjectContactOfPagePainter::GetPaintObjectCount() const { - namespace contact - { - sal_uInt32 ObjectContactOfPagePainter::GetPaintObjectCount() const - { - return (GetStartPage() ? 1L : 0L); - } + return (GetStartPage() ? 1L : 0L); +} - ViewContact& ObjectContactOfPagePainter::GetPaintObjectViewContact(sal_uInt32 /*nIndex*/) const - { - DBG_ASSERT(GetStartPage(), "ObjectContactOfPagePainter::GetPaintObjectViewContact: no StartPage set (!)"); - return GetStartPage()->GetViewContact(); - } +ViewContact& ObjectContactOfPagePainter::GetPaintObjectViewContact(sal_uInt32 /*nIndex*/) const +{ + DBG_ASSERT(GetStartPage(), "ObjectContactOfPagePainter::GetPaintObjectViewContact: no StartPage set (!)"); + return GetStartPage()->GetViewContact(); +} + +ObjectContactOfPagePainter::ObjectContactOfPagePainter( + const SdrPage* pPage, + ObjectContact& rOriginalObjectContact) +: ObjectContactPainter(), + mrOriginalObjectContact(rOriginalObjectContact), + mxStartPage(const_cast< SdrPage* >(pPage)) // no SdrPageWeakRef available to hold a const SdrPage* +{ +} - ObjectContactOfPagePainter::ObjectContactOfPagePainter( - const SdrPage* pPage, - ObjectContact& rOriginalObjectContact) - : ObjectContactPainter(), - mrOriginalObjectContact(rOriginalObjectContact), - mxStartPage(const_cast< SdrPage* >(pPage)) // no SdrPageWeakRef available to hold a const SdrPage* - { - } +ObjectContactOfPagePainter::~ObjectContactOfPagePainter() +{ +} - ObjectContactOfPagePainter::~ObjectContactOfPagePainter() - { - } +void ObjectContactOfPagePainter::SetStartPage(const SdrPage* pPage) +{ + if(pPage != GetStartPage()) + { + mxStartPage.reset(const_cast< SdrPage* >(pPage)); // no SdrPageWeakRef available to hold a const SdrPage* + } +} - void ObjectContactOfPagePainter::SetStartPage(const SdrPage* pPage) - { - if(pPage != GetStartPage()) - { - mxStartPage.reset(const_cast< SdrPage* >(pPage)); // no SdrPageWeakRef available to hold a const SdrPage* - } - } +OutputDevice* ObjectContactOfPagePainter::TryToGetOutputDevice() const +{ + return mrOriginalObjectContact.TryToGetOutputDevice(); +} - OutputDevice* ObjectContactOfPagePainter::TryToGetOutputDevice() const - { - return mrOriginalObjectContact.TryToGetOutputDevice(); - } - } // end of namespace contact -} // end of namespace sdr +}} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/contact/viewcontactofe3d.cxx b/svx/source/sdr/contact/viewcontactofe3d.cxx index 810a9eca9496..e5d9f689e5df 100644 --- a/svx/source/sdr/contact/viewcontactofe3d.cxx +++ b/svx/source/sdr/contact/viewcontactofe3d.cxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #include <svx/sdr/contact/viewcontactofe3d.hxx> #include <sdr/contact/viewobjectcontactofe3d.hxx> #include <svx/obj3d.hxx> @@ -30,173 +29,168 @@ #include <drawinglayer/attribute/sdrlightattribute3d.hxx> #include <drawinglayer/attribute/sdrlineattribute.hxx> +namespace { - -namespace +const sdr::contact::ViewContactOfE3dScene* tryToFindVCOfE3DScene( + const sdr::contact::ViewContact& rCandidate, + basegfx::B3DHomMatrix& o_rInBetweenObjectTransform) { - const sdr::contact::ViewContactOfE3dScene* tryToFindVCOfE3DScene( - const sdr::contact::ViewContact& rCandidate, - basegfx::B3DHomMatrix& o_rInBetweenObjectTransform) + const sdr::contact::ViewContactOfE3dScene* pSceneParent = + dynamic_cast< const sdr::contact::ViewContactOfE3dScene* >(rCandidate.GetParentContact()); + + if(pSceneParent) { - const sdr::contact::ViewContactOfE3dScene* pSceneParent = - dynamic_cast< const sdr::contact::ViewContactOfE3dScene* >(rCandidate.GetParentContact()); + // each 3d object (including in-between scenes) should have a scene as parent + const sdr::contact::ViewContactOfE3dScene* pSceneParentParent = + dynamic_cast< const sdr::contact::ViewContactOfE3dScene* >(pSceneParent->GetParentContact()); - if(pSceneParent) + if(pSceneParentParent) { - // each 3d object (including in-between scenes) should have a scene as parent - const sdr::contact::ViewContactOfE3dScene* pSceneParentParent = - dynamic_cast< const sdr::contact::ViewContactOfE3dScene* >(pSceneParent->GetParentContact()); - - if(pSceneParentParent) - { - // the parent scene of rCandidate is a in-between scene, call recursively and collect - // the in-between scene's object transformation part in o_rInBetweenObjectTransform - const basegfx::B3DHomMatrix& rSceneParentTransform = pSceneParent->GetE3dScene().GetTransform(); - o_rInBetweenObjectTransform = rSceneParentTransform * o_rInBetweenObjectTransform; - return tryToFindVCOfE3DScene(*pSceneParent, o_rInBetweenObjectTransform); - } - else - { - // the parent scene is the outmost scene - return pSceneParent; - } + // the parent scene of rCandidate is a in-between scene, call recursively and collect + // the in-between scene's object transformation part in o_rInBetweenObjectTransform + const basegfx::B3DHomMatrix& rSceneParentTransform = pSceneParent->GetE3dScene().GetTransform(); + o_rInBetweenObjectTransform = rSceneParentTransform * o_rInBetweenObjectTransform; + return tryToFindVCOfE3DScene(*pSceneParent, o_rInBetweenObjectTransform); + } + else + { + // the parent scene is the outmost scene + return pSceneParent; } - - // object hierarchy structure is incorrect; no result - return 0; } -} // end of anonymous namespace + // object hierarchy structure is incorrect; no result + return 0; +} +} // end of anonymous namespace + +namespace sdr { namespace contact { -namespace sdr +drawinglayer::primitive2d::Primitive2DSequence ViewContactOfE3d::impCreateWithGivenPrimitive3DSequence( + const drawinglayer::primitive3d::Primitive3DSequence& rxContent3D) const { - namespace contact + drawinglayer::primitive2d::Primitive2DSequence xRetval; + + if(rxContent3D.hasElements()) { - drawinglayer::primitive2d::Primitive2DSequence ViewContactOfE3d::impCreateWithGivenPrimitive3DSequence( - const drawinglayer::primitive3d::Primitive3DSequence& rxContent3D) const + // try to get the outmost ViewObjectContactOfE3dScene for this single 3d object, + // the ones on the way there are grouping scenes. Collect the in-between scene's + // transformations to build a correct object transformation for the embedded + // object + basegfx::B3DHomMatrix aInBetweenObjectTransform; + const ViewContactOfE3dScene* pVCOfE3DScene = tryToFindVCOfE3DScene(*this, aInBetweenObjectTransform); + + if(pVCOfE3DScene) { - drawinglayer::primitive2d::Primitive2DSequence xRetval; + basegfx::B3DVector aLightNormal; + const double fShadowSlant(pVCOfE3DScene->getSdrSceneAttribute().getShadowSlant()); + const basegfx::B3DRange& rAllContentRange = pVCOfE3DScene->getAllContentRange3D(); + drawinglayer::geometry::ViewInformation3D aViewInformation3D(pVCOfE3DScene->getViewInformation3D()); - if(rxContent3D.hasElements()) + if(pVCOfE3DScene->getSdrLightingAttribute().getLightVector().size()) { - // try to get the outmost ViewObjectContactOfE3dScene for this single 3d object, - // the ones on the way there are grouping scenes. Collect the in-between scene's - // transformations to build a correct object transformation for the embedded - // object - basegfx::B3DHomMatrix aInBetweenObjectTransform; - const ViewContactOfE3dScene* pVCOfE3DScene = tryToFindVCOfE3DScene(*this, aInBetweenObjectTransform); - - if(pVCOfE3DScene) - { - basegfx::B3DVector aLightNormal; - const double fShadowSlant(pVCOfE3DScene->getSdrSceneAttribute().getShadowSlant()); - const basegfx::B3DRange& rAllContentRange = pVCOfE3DScene->getAllContentRange3D(); - drawinglayer::geometry::ViewInformation3D aViewInformation3D(pVCOfE3DScene->getViewInformation3D()); - - if(pVCOfE3DScene->getSdrLightingAttribute().getLightVector().size()) - { - // get light normal from first light and normalize - aLightNormal = pVCOfE3DScene->getSdrLightingAttribute().getLightVector()[0].getDirection(); - aLightNormal.normalize(); - } - - if(!aInBetweenObjectTransform.isIdentity()) - { - // if aInBetweenObjectTransform is used, create combined ViewInformation3D which - // contains the correct object transformation for the embedded 3d object - aViewInformation3D = drawinglayer::geometry::ViewInformation3D( - aViewInformation3D.getObjectTransformation() * aInBetweenObjectTransform, - aViewInformation3D.getOrientation(), - aViewInformation3D.getProjection(), - aViewInformation3D.getDeviceToView(), - aViewInformation3D.getViewTime(), - aViewInformation3D.getExtendedInformationSequence()); - } - - // create embedded 2d primitive and add. LightNormal and ShadowSlant are needed for evtl. - // 3D shadow extraction for correct B2DRange calculation (shadow is part of the object) - const drawinglayer::primitive2d::Primitive2DReference xReference( - new drawinglayer::primitive2d::Embedded3DPrimitive2D( - rxContent3D, - pVCOfE3DScene->getObjectTransformation(), - aViewInformation3D, - aLightNormal, - fShadowSlant, - rAllContentRange)); - - xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); - } + // get light normal from first light and normalize + aLightNormal = pVCOfE3DScene->getSdrLightingAttribute().getLightVector()[0].getDirection(); + aLightNormal.normalize(); } - return xRetval; - } + if(!aInBetweenObjectTransform.isIdentity()) + { + // if aInBetweenObjectTransform is used, create combined ViewInformation3D which + // contains the correct object transformation for the embedded 3d object + aViewInformation3D = drawinglayer::geometry::ViewInformation3D( + aViewInformation3D.getObjectTransformation() * aInBetweenObjectTransform, + aViewInformation3D.getOrientation(), + aViewInformation3D.getProjection(), + aViewInformation3D.getDeviceToView(), + aViewInformation3D.getViewTime(), + aViewInformation3D.getExtendedInformationSequence()); + } - ViewContactOfE3d::ViewContactOfE3d(E3dObject& rSdrObject) - : ViewContactOfSdrObj(rSdrObject) - { + // create embedded 2d primitive and add. LightNormal and ShadowSlant are needed for evtl. + // 3D shadow extraction for correct B2DRange calculation (shadow is part of the object) + const drawinglayer::primitive2d::Primitive2DReference xReference( + new drawinglayer::primitive2d::Embedded3DPrimitive2D( + rxContent3D, + pVCOfE3DScene->getObjectTransformation(), + aViewInformation3D, + aLightNormal, + fShadowSlant, + rAllContentRange)); + + xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); } + } - ViewContactOfE3d::~ViewContactOfE3d() - { - } + return xRetval; +} - drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3d::getVIP3DSWithoutObjectTransform() const - { - // local up-to-date checks. Create new list and compare. - drawinglayer::primitive3d::Primitive3DSequence xNew(createViewIndependentPrimitive3DSequence()); +ViewContactOfE3d::ViewContactOfE3d(E3dObject& rSdrObject) +: ViewContactOfSdrObj(rSdrObject) +{ +} - if(!drawinglayer::primitive3d::arePrimitive3DSequencesEqual(mxViewIndependentPrimitive3DSequence, xNew)) - { - // has changed, copy content - const_cast< ViewContactOfE3d* >(this)->mxViewIndependentPrimitive3DSequence = xNew; - } +ViewContactOfE3d::~ViewContactOfE3d() +{ +} - // return current Primitive2DSequence - return mxViewIndependentPrimitive3DSequence; - } +drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3d::getVIP3DSWithoutObjectTransform() const +{ + // local up-to-date checks. Create new list and compare. + drawinglayer::primitive3d::Primitive3DSequence xNew(createViewIndependentPrimitive3DSequence()); - drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3d::getViewIndependentPrimitive3DSequence() const - { - // get sequence without object transform - drawinglayer::primitive3d::Primitive3DSequence xRetval(getVIP3DSWithoutObjectTransform()); + if(!drawinglayer::primitive3d::arePrimitive3DSequencesEqual(mxViewIndependentPrimitive3DSequence, xNew)) + { + // has changed, copy content + const_cast< ViewContactOfE3d* >(this)->mxViewIndependentPrimitive3DSequence = xNew; + } - if(xRetval.hasElements()) - { - // add object transform if it's used - const basegfx::B3DHomMatrix& rObjectTransform(GetE3dObject().GetTransform()); - - if(!rObjectTransform.isIdentity()) - { - const drawinglayer::primitive3d::Primitive3DReference xReference( - new drawinglayer::primitive3d::TransformPrimitive3D( - rObjectTransform, - xRetval)); - - xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1); - } - } + // return current Primitive2DSequence + return mxViewIndependentPrimitive3DSequence; +} - // return current Primitive2DSequence - return xRetval; - } +drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3d::getViewIndependentPrimitive3DSequence() const +{ + // get sequence without object transform + drawinglayer::primitive3d::Primitive3DSequence xRetval(getVIP3DSWithoutObjectTransform()); - drawinglayer::primitive2d::Primitive2DSequence ViewContactOfE3d::createViewIndependentPrimitive2DSequence() const - { - // also need to create a 2D embedding when the view-independent part is requested, - // see view-dependent part in ViewObjectContactOfE3d::createPrimitive2DSequence - // get 3d primitive vector, isPrimitiveVisible() is done in 3d creator - return impCreateWithGivenPrimitive3DSequence(getViewIndependentPrimitive3DSequence()); - } + if(xRetval.hasElements()) + { + // add object transform if it's used + const basegfx::B3DHomMatrix& rObjectTransform(GetE3dObject().GetTransform()); - ViewObjectContact& ViewContactOfE3d::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) + if(!rObjectTransform.isIdentity()) { - ViewObjectContact* pRetval = new ViewObjectContactOfE3d(rObjectContact, *this); - DBG_ASSERT(pRetval, "ViewContactOfE3d::CreateObjectSpecificViewObjectContact() failed (!)"); + const drawinglayer::primitive3d::Primitive3DReference xReference( + new drawinglayer::primitive3d::TransformPrimitive3D( + rObjectTransform, + xRetval)); - return *pRetval; + xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1); } - } // end of namespace contact -} // end of namespace sdr + } + + // return current Primitive2DSequence + return xRetval; +} + +drawinglayer::primitive2d::Primitive2DSequence ViewContactOfE3d::createViewIndependentPrimitive2DSequence() const +{ + // also need to create a 2D embedding when the view-independent part is requested, + // see view-dependent part in ViewObjectContactOfE3d::createPrimitive2DSequence + // get 3d primitive vector, isPrimitiveVisible() is done in 3d creator + return impCreateWithGivenPrimitive3DSequence(getViewIndependentPrimitive3DSequence()); +} + +ViewObjectContact& ViewContactOfE3d::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) +{ + ViewObjectContact* pRetval = new ViewObjectContactOfE3d(rObjectContact, *this); + DBG_ASSERT(pRetval, "ViewContactOfE3d::CreateObjectSpecificViewObjectContact() failed (!)"); + + return *pRetval; +} + +}} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/contact/viewcontactofe3dscene.cxx b/svx/source/sdr/contact/viewcontactofe3dscene.cxx index 9a80884d28ff..dfd4e660fd28 100644 --- a/svx/source/sdr/contact/viewcontactofe3dscene.cxx +++ b/svx/source/sdr/contact/viewcontactofe3dscene.cxx @@ -34,437 +34,430 @@ #include <drawinglayer/primitive3d/transformprimitive3d.hxx> #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx> - - using namespace com::sun::star; +namespace { - -namespace +// pActiveVC is only true if ghosted is still activated and maybe needs to be switched off in this path +void createSubPrimitive3DVector( + const sdr::contact::ViewContact& rCandidate, + drawinglayer::primitive3d::Primitive3DSequence& o_rAllTarget, + drawinglayer::primitive3d::Primitive3DSequence* o_pVisibleTarget, + const SetOfByte* pVisibleLayerSet, + const bool bTestSelectedVisibility) { - // pActiveVC is only true if ghosted is still activated and maybe needs to be switched off in this path - void createSubPrimitive3DVector( - const sdr::contact::ViewContact& rCandidate, - drawinglayer::primitive3d::Primitive3DSequence& o_rAllTarget, - drawinglayer::primitive3d::Primitive3DSequence* o_pVisibleTarget, - const SetOfByte* pVisibleLayerSet, - const bool bTestSelectedVisibility) + const sdr::contact::ViewContactOfE3dScene* pViewContactOfE3dScene = dynamic_cast< const sdr::contact::ViewContactOfE3dScene* >(&rCandidate); + + if(pViewContactOfE3dScene) { - const sdr::contact::ViewContactOfE3dScene* pViewContactOfE3dScene = dynamic_cast< const sdr::contact::ViewContactOfE3dScene* >(&rCandidate); + const sal_uInt32 nChildrenCount(rCandidate.GetObjectCount()); - if(pViewContactOfE3dScene) + if(nChildrenCount) { - const sal_uInt32 nChildrenCount(rCandidate.GetObjectCount()); + // provide new collection sequences + drawinglayer::primitive3d::Primitive3DSequence aNewAllTarget; + drawinglayer::primitive3d::Primitive3DSequence aNewVisibleTarget; - if(nChildrenCount) + // add children recursively + for(sal_uInt32 a(0L); a < nChildrenCount; a++) { - // provide new collection sequences - drawinglayer::primitive3d::Primitive3DSequence aNewAllTarget; - drawinglayer::primitive3d::Primitive3DSequence aNewVisibleTarget; - - // add children recursively - for(sal_uInt32 a(0L); a < nChildrenCount; a++) - { - createSubPrimitive3DVector( - rCandidate.GetViewContact(a), - aNewAllTarget, - o_pVisibleTarget ? &aNewVisibleTarget : 0, - pVisibleLayerSet, - bTestSelectedVisibility); - } + createSubPrimitive3DVector( + rCandidate.GetViewContact(a), + aNewAllTarget, + o_pVisibleTarget ? &aNewVisibleTarget : 0, + pVisibleLayerSet, + bTestSelectedVisibility); + } - // create transform primitive for the created content combining content and transformtion - const drawinglayer::primitive3d::Primitive3DReference xReference(new drawinglayer::primitive3d::TransformPrimitive3D( - pViewContactOfE3dScene->GetE3dScene().GetTransform(), - aNewAllTarget)); + // create transform primitive for the created content combining content and transformtion + const drawinglayer::primitive3d::Primitive3DReference xReference(new drawinglayer::primitive3d::TransformPrimitive3D( + pViewContactOfE3dScene->GetE3dScene().GetTransform(), + aNewAllTarget)); - // add created content to all target - drawinglayer::primitive3d::appendPrimitive3DReferenceToPrimitive3DSequence(o_rAllTarget, xReference); + // add created content to all target + drawinglayer::primitive3d::appendPrimitive3DReferenceToPrimitive3DSequence(o_rAllTarget, xReference); - // add created content to visibiel target if exists - if(o_pVisibleTarget) - { - drawinglayer::primitive3d::appendPrimitive3DReferenceToPrimitive3DSequence(*o_pVisibleTarget, xReference); - } + // add created content to visibiel target if exists + if(o_pVisibleTarget) + { + drawinglayer::primitive3d::appendPrimitive3DReferenceToPrimitive3DSequence(*o_pVisibleTarget, xReference); } } - else + } + else + { + // access view independent representation of rCandidate + const sdr::contact::ViewContactOfE3d* pViewContactOfE3d = dynamic_cast< const sdr::contact::ViewContactOfE3d* >(&rCandidate); + + if(pViewContactOfE3d) { - // access view independent representation of rCandidate - const sdr::contact::ViewContactOfE3d* pViewContactOfE3d = dynamic_cast< const sdr::contact::ViewContactOfE3d* >(&rCandidate); + drawinglayer::primitive3d::Primitive3DSequence xPrimitive3DSeq(pViewContactOfE3d->getViewIndependentPrimitive3DSequence()); - if(pViewContactOfE3d) + if(xPrimitive3DSeq.hasElements()) { - drawinglayer::primitive3d::Primitive3DSequence xPrimitive3DSeq(pViewContactOfE3d->getViewIndependentPrimitive3DSequence()); + // add to all target vector + drawinglayer::primitive3d::appendPrimitive3DSequenceToPrimitive3DSequence(o_rAllTarget, xPrimitive3DSeq); - if(xPrimitive3DSeq.hasElements()) + if(o_pVisibleTarget) { - // add to all target vector - drawinglayer::primitive3d::appendPrimitive3DSequenceToPrimitive3DSequence(o_rAllTarget, xPrimitive3DSeq); + // test visibility. Primitive is visible when both tests are true (AND) + bool bVisible(true); + + if(pVisibleLayerSet) + { + // test layer visibility + const E3dObject& rE3dObject = pViewContactOfE3d->GetE3dObject(); + const SdrLayerID aLayerID(rE3dObject.GetLayer()); + + bVisible = pVisibleLayerSet->IsSet(aLayerID); + } + + if(bVisible && bTestSelectedVisibility) + { + // test selected visibility (see 3D View's DrawMarkedObj implementation) + const E3dObject& rE3dObject = pViewContactOfE3d->GetE3dObject(); - if(o_pVisibleTarget) + bVisible = rE3dObject.GetSelected(); + } + + if(bVisible && o_pVisibleTarget) { - // test visibility. Primitive is visible when both tests are true (AND) - bool bVisible(true); - - if(pVisibleLayerSet) - { - // test layer visibility - const E3dObject& rE3dObject = pViewContactOfE3d->GetE3dObject(); - const SdrLayerID aLayerID(rE3dObject.GetLayer()); - - bVisible = pVisibleLayerSet->IsSet(aLayerID); - } - - if(bVisible && bTestSelectedVisibility) - { - // test selected visibility (see 3D View's DrawMarkedObj implementation) - const E3dObject& rE3dObject = pViewContactOfE3d->GetE3dObject(); - - bVisible = rE3dObject.GetSelected(); - } - - if(bVisible && o_pVisibleTarget) - { - // add to visible target vector - drawinglayer::primitive3d::appendPrimitive3DSequenceToPrimitive3DSequence(*o_pVisibleTarget, xPrimitive3DSeq); - } + // add to visible target vector + drawinglayer::primitive3d::appendPrimitive3DSequenceToPrimitive3DSequence(*o_pVisibleTarget, xPrimitive3DSeq); } } } } } -} // end of anonymous namespace +} + +} +namespace sdr { namespace contact { +// Create a Object-Specific ViewObjectContact, set ViewContact and +// ObjectContact. Always needs to return something. +ViewObjectContact& ViewContactOfE3dScene::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) +{ + ViewObjectContact* pRetval = new ViewObjectContactOfE3dScene(rObjectContact, *this); + DBG_ASSERT(pRetval, "ViewContactOfE3dScene::CreateObjectSpecificViewObjectContact() failed (!)"); + + return *pRetval; +} + +ViewContactOfE3dScene::ViewContactOfE3dScene(E3dScene& rScene) +: ViewContactOfSdrObj(rScene), + maViewInformation3D(), + maObjectTransformation(), + maSdrSceneAttribute(), + maSdrLightingAttribute() +{ +} -namespace sdr +void ViewContactOfE3dScene::createViewInformation3D(const basegfx::B3DRange& rContentRange) { - namespace contact + basegfx::B3DHomMatrix aTransformation; + basegfx::B3DHomMatrix aOrientation; + basegfx::B3DHomMatrix aProjection; + basegfx::B3DHomMatrix aDeviceToView; + + // create transformation (scene as group's transformation) + // For historical reasons, the outmost scene's transformation is handles as part of the + // view transformation. This means that the BoundRect of the contained 3D Objects is + // without that transformation and makes it necessary to NOT add the first scene to the + // Primitive3DSequence of contained objects. { - // Create a Object-Specific ViewObjectContact, set ViewContact and - // ObjectContact. Always needs to return something. - ViewObjectContact& ViewContactOfE3dScene::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) - { - ViewObjectContact* pRetval = new ViewObjectContactOfE3dScene(rObjectContact, *this); - DBG_ASSERT(pRetval, "ViewContactOfE3dScene::CreateObjectSpecificViewObjectContact() failed (!)"); + aTransformation = GetE3dScene().GetTransform(); + } - return *pRetval; - } + // create orientation (world to camera coordinate system) + { + // calculate orientation from VRP, VPN and VUV + const B3dCamera& rSceneCamera = GetE3dScene().GetCameraSet(); + const basegfx::B3DPoint aVRP(rSceneCamera.GetVRP()); + const basegfx::B3DVector aVPN(rSceneCamera.GetVRP()); + const basegfx::B3DVector aVUV(rSceneCamera.GetVUV()); - ViewContactOfE3dScene::ViewContactOfE3dScene(E3dScene& rScene) - : ViewContactOfSdrObj(rScene), - maViewInformation3D(), - maObjectTransformation(), - maSdrSceneAttribute(), - maSdrLightingAttribute() - { - } + aOrientation.orientation(aVRP, aVPN, aVUV); + } - void ViewContactOfE3dScene::createViewInformation3D(const basegfx::B3DRange& rContentRange) - { - basegfx::B3DHomMatrix aTransformation; - basegfx::B3DHomMatrix aOrientation; - basegfx::B3DHomMatrix aProjection; - basegfx::B3DHomMatrix aDeviceToView; - - // create transformation (scene as group's transformation) - // For historical reasons, the outmost scene's transformation is handles as part of the - // view transformation. This means that the BoundRect of the contained 3D Objects is - // without that transformation and makes it necessary to NOT add the first scene to the - // Primitive3DSequence of contained objects. - { - aTransformation = GetE3dScene().GetTransform(); - } + // create projection (camera coordinate system to relative 2d where X,Y and Z are [0.0 .. 1.0]) + { + const basegfx::B3DHomMatrix aWorldToCamera(aOrientation * aTransformation); + basegfx::B3DRange aCameraRange(rContentRange); + aCameraRange.transform(aWorldToCamera); - // create orientation (world to camera coordinate system) - { - // calculate orientation from VRP, VPN and VUV - const B3dCamera& rSceneCamera = GetE3dScene().GetCameraSet(); - const basegfx::B3DPoint aVRP(rSceneCamera.GetVRP()); - const basegfx::B3DVector aVPN(rSceneCamera.GetVRP()); - const basegfx::B3DVector aVUV(rSceneCamera.GetVUV()); + // remember Z-Values, but change orientation + const double fMinZ(-aCameraRange.getMaxZ()); + const double fMaxZ(-aCameraRange.getMinZ()); - aOrientation.orientation(aVRP, aVPN, aVUV); - } + // construct temporary matrix from world to device. Use unit values here to measure expansion + basegfx::B3DHomMatrix aWorldToDevice(aWorldToCamera); + const drawinglayer::attribute::SdrSceneAttribute& rSdrSceneAttribute = getSdrSceneAttribute(); - // create projection (camera coordinate system to relative 2d where X,Y and Z are [0.0 .. 1.0]) - { - const basegfx::B3DHomMatrix aWorldToCamera(aOrientation * aTransformation); - basegfx::B3DRange aCameraRange(rContentRange); - aCameraRange.transform(aWorldToCamera); + if(::com::sun::star::drawing::ProjectionMode_PERSPECTIVE == rSdrSceneAttribute.getProjectionMode()) + { + aWorldToDevice.frustum(-1.0, 1.0, -1.0, 1.0, fMinZ, fMaxZ); + } + else + { + aWorldToDevice.ortho(-1.0, 1.0, -1.0, 1.0, fMinZ, fMaxZ); + } - // remember Z-Values, but change orientation - const double fMinZ(-aCameraRange.getMaxZ()); - const double fMaxZ(-aCameraRange.getMinZ()); + // create B3DRange in device. This will create the real used ranges + // in camera space. Do not use the Z-Values, though. + basegfx::B3DRange aDeviceRange(rContentRange); + aDeviceRange.transform(aWorldToDevice); - // construct temporary matrix from world to device. Use unit values here to measure expansion - basegfx::B3DHomMatrix aWorldToDevice(aWorldToCamera); - const drawinglayer::attribute::SdrSceneAttribute& rSdrSceneAttribute = getSdrSceneAttribute(); + // set projection + if(::com::sun::star::drawing::ProjectionMode_PERSPECTIVE == rSdrSceneAttribute.getProjectionMode()) + { + aProjection.frustum( + aDeviceRange.getMinX(), aDeviceRange.getMaxX(), + aDeviceRange.getMinY(), aDeviceRange.getMaxY(), + fMinZ, fMaxZ); + } + else + { + aProjection.ortho( + aDeviceRange.getMinX(), aDeviceRange.getMaxX(), + aDeviceRange.getMinY(), aDeviceRange.getMaxY(), + fMinZ, fMaxZ); + } + } - if(::com::sun::star::drawing::ProjectionMode_PERSPECTIVE == rSdrSceneAttribute.getProjectionMode()) - { - aWorldToDevice.frustum(-1.0, 1.0, -1.0, 1.0, fMinZ, fMaxZ); - } - else - { - aWorldToDevice.ortho(-1.0, 1.0, -1.0, 1.0, fMinZ, fMaxZ); - } + // create device to view transform + { + // create standard deviceToView projection for geometry + // input is [-1.0 .. 1.0] in X,Y and Z. bring to [0.0 .. 1.0]. Also + // necessary to flip Y due to screen orientation + // Z is not needed, but will also be brought to [0.0 .. 1.0] + aDeviceToView.scale(0.5, -0.5, 0.5); + aDeviceToView.translate(0.5, 0.5, 0.5); + } - // create B3DRange in device. This will create the real used ranges - // in camera space. Do not use the Z-Values, though. - basegfx::B3DRange aDeviceRange(rContentRange); - aDeviceRange.transform(aWorldToDevice); + const uno::Sequence< beans::PropertyValue > aEmptyProperties; + maViewInformation3D = drawinglayer::geometry::ViewInformation3D( + aTransformation, aOrientation, aProjection, + aDeviceToView, 0.0, aEmptyProperties); +} - // set projection - if(::com::sun::star::drawing::ProjectionMode_PERSPECTIVE == rSdrSceneAttribute.getProjectionMode()) - { - aProjection.frustum( - aDeviceRange.getMinX(), aDeviceRange.getMaxX(), - aDeviceRange.getMinY(), aDeviceRange.getMaxY(), - fMinZ, fMaxZ); - } - else - { - aProjection.ortho( - aDeviceRange.getMinX(), aDeviceRange.getMaxX(), - aDeviceRange.getMinY(), aDeviceRange.getMaxY(), - fMinZ, fMaxZ); - } - } +void ViewContactOfE3dScene::createObjectTransformation() +{ + // create 2d Object Transformation from relative point in 2d scene to world + Rectangle aRectangle = GetE3dScene().GetSnapRect(); + // Hack for calc, transform position of object according + // to current zoom so as objects relative position to grid + // appears stable + aRectangle += GetE3dScene().GetGridOffset(); + maObjectTransformation.set(0, 0, aRectangle.getWidth()); + maObjectTransformation.set(1, 1, aRectangle.getHeight()); + maObjectTransformation.set(0, 2, aRectangle.Left()); + maObjectTransformation.set(1, 2, aRectangle.Top()); +} + +void ViewContactOfE3dScene::createSdrSceneAttribute() +{ + const SfxItemSet& rItemSet = GetE3dScene().GetMergedItemSet(); + maSdrSceneAttribute = drawinglayer::primitive2d::createNewSdrSceneAttribute(rItemSet); +} - // create device to view transform - { - // create standard deviceToView projection for geometry - // input is [-1.0 .. 1.0] in X,Y and Z. bring to [0.0 .. 1.0]. Also - // necessary to flip Y due to screen orientation - // Z is not needed, but will also be brought to [0.0 .. 1.0] - aDeviceToView.scale(0.5, -0.5, 0.5); - aDeviceToView.translate(0.5, 0.5, 0.5); - } +void ViewContactOfE3dScene::createSdrLightingAttribute() +{ + const SfxItemSet& rItemSet = GetE3dScene().GetMergedItemSet(); + maSdrLightingAttribute = drawinglayer::primitive2d::createNewSdrLightingAttribute(rItemSet); +} - const uno::Sequence< beans::PropertyValue > aEmptyProperties; - maViewInformation3D = drawinglayer::geometry::ViewInformation3D( - aTransformation, aOrientation, aProjection, - aDeviceToView, 0.0, aEmptyProperties); - } +drawinglayer::primitive2d::Primitive2DSequence ViewContactOfE3dScene::createScenePrimitive2DSequence( + const SetOfByte* pLayerVisibility) const +{ + drawinglayer::primitive2d::Primitive2DSequence xRetval; + const sal_uInt32 nChildrenCount(GetObjectCount()); - void ViewContactOfE3dScene::createObjectTransformation() + if(nChildrenCount) + { + // create 3d scene primitive with visible content tested against rLayerVisibility + drawinglayer::primitive3d::Primitive3DSequence aAllSequence; + drawinglayer::primitive3d::Primitive3DSequence aVisibleSequence; + const bool bTestLayerVisibility(0 != pLayerVisibility); + const bool bTestSelectedVisibility(GetE3dScene().GetDrawOnlySelected()); + const bool bTestVisibility(bTestLayerVisibility || bTestSelectedVisibility); + + // add children recursively. Do NOT start with (*this), this would create + // a 3D transformPrimitive for the start scene. While this is theoretically not + // a bad thing, for historical reasons the transformation of the outmost scene + // is seen as part of the ViewTransformation (see text in createViewInformation3D) + for(sal_uInt32 a(0L); a < nChildrenCount; a++) { - // create 2d Object Transformation from relative point in 2d scene to world - Rectangle aRectangle = GetE3dScene().GetSnapRect(); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - aRectangle += GetE3dScene().GetGridOffset(); - maObjectTransformation.set(0, 0, aRectangle.getWidth()); - maObjectTransformation.set(1, 1, aRectangle.getHeight()); - maObjectTransformation.set(0, 2, aRectangle.Left()); - maObjectTransformation.set(1, 2, aRectangle.Top()); + createSubPrimitive3DVector( + GetViewContact(a), + aAllSequence, + bTestLayerVisibility ? &aVisibleSequence : 0, + bTestLayerVisibility ? pLayerVisibility : 0, + bTestSelectedVisibility); } - void ViewContactOfE3dScene::createSdrSceneAttribute() - { - const SfxItemSet& rItemSet = GetE3dScene().GetMergedItemSet(); - maSdrSceneAttribute = drawinglayer::primitive2d::createNewSdrSceneAttribute(rItemSet); - } + const sal_uInt32 nAllSize(aAllSequence.hasElements() ? aAllSequence.getLength() : 0); + const sal_uInt32 nVisibleSize(aVisibleSequence.hasElements() ? aVisibleSequence.getLength() : 0); - void ViewContactOfE3dScene::createSdrLightingAttribute() + if((bTestVisibility && nVisibleSize) || nAllSize) { - const SfxItemSet& rItemSet = GetE3dScene().GetMergedItemSet(); - maSdrLightingAttribute = drawinglayer::primitive2d::createNewSdrLightingAttribute(rItemSet); + // for getting the 3D range using getB3DRangeFromPrimitive3DSequence a ViewInformation3D + // needs to be given for evtl. decompositions. At the same time createViewInformation3D + // currently is based on creating the target-ViewInformation3D using a given range. To + // get the true range, use a neutral ViewInformation3D here. This leaves all matrices + // on identity and the time on 0.0. + const uno::Sequence< beans::PropertyValue > aEmptyProperties; + const drawinglayer::geometry::ViewInformation3D aNeutralViewInformation3D(aEmptyProperties); + const basegfx::B3DRange aContentRange( + drawinglayer::primitive3d::getB3DRangeFromPrimitive3DSequence(aAllSequence, aNeutralViewInformation3D)); + + // create 2d primitive 3dscene with generated sub-list from collector + const drawinglayer::primitive2d::Primitive2DReference xReference( + new drawinglayer::primitive2d::ScenePrimitive2D( + bTestVisibility ? aVisibleSequence : aAllSequence, + getSdrSceneAttribute(), + getSdrLightingAttribute(), + getObjectTransformation(), + getViewInformation3D(aContentRange))); + + xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); } + } - drawinglayer::primitive2d::Primitive2DSequence ViewContactOfE3dScene::createScenePrimitive2DSequence( - const SetOfByte* pLayerVisibility) const - { - drawinglayer::primitive2d::Primitive2DSequence xRetval; - const sal_uInt32 nChildrenCount(GetObjectCount()); - - if(nChildrenCount) - { - // create 3d scene primitive with visible content tested against rLayerVisibility - drawinglayer::primitive3d::Primitive3DSequence aAllSequence; - drawinglayer::primitive3d::Primitive3DSequence aVisibleSequence; - const bool bTestLayerVisibility(0 != pLayerVisibility); - const bool bTestSelectedVisibility(GetE3dScene().GetDrawOnlySelected()); - const bool bTestVisibility(bTestLayerVisibility || bTestSelectedVisibility); - - // add children recursively. Do NOT start with (*this), this would create - // a 3D transformPrimitive for the start scene. While this is theoretically not - // a bad thing, for historical reasons the transformation of the outmost scene - // is seen as part of the ViewTransformation (see text in createViewInformation3D) - for(sal_uInt32 a(0L); a < nChildrenCount; a++) - { - createSubPrimitive3DVector( - GetViewContact(a), - aAllSequence, - bTestLayerVisibility ? &aVisibleSequence : 0, - bTestLayerVisibility ? pLayerVisibility : 0, - bTestSelectedVisibility); - } + // always append an invisible outline for the cases where no visible content exists + drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, + drawinglayer::primitive2d::createHiddenGeometryPrimitives2D( + false, getObjectTransformation())); - const sal_uInt32 nAllSize(aAllSequence.hasElements() ? aAllSequence.getLength() : 0); - const sal_uInt32 nVisibleSize(aVisibleSequence.hasElements() ? aVisibleSequence.getLength() : 0); + return xRetval; +} - if((bTestVisibility && nVisibleSize) || nAllSize) - { - // for getting the 3D range using getB3DRangeFromPrimitive3DSequence a ViewInformation3D - // needs to be given for evtl. decompositions. At the same time createViewInformation3D - // currently is based on creating the target-ViewInformation3D using a given range. To - // get the true range, use a neutral ViewInformation3D here. This leaves all matrices - // on identity and the time on 0.0. - const uno::Sequence< beans::PropertyValue > aEmptyProperties; - const drawinglayer::geometry::ViewInformation3D aNeutralViewInformation3D(aEmptyProperties); - const basegfx::B3DRange aContentRange( - drawinglayer::primitive3d::getB3DRangeFromPrimitive3DSequence(aAllSequence, aNeutralViewInformation3D)); - - // create 2d primitive 3dscene with generated sub-list from collector - const drawinglayer::primitive2d::Primitive2DReference xReference( - new drawinglayer::primitive2d::ScenePrimitive2D( - bTestVisibility ? aVisibleSequence : aAllSequence, - getSdrSceneAttribute(), - getSdrLightingAttribute(), - getObjectTransformation(), - getViewInformation3D(aContentRange))); - - xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); - } - } +drawinglayer::primitive2d::Primitive2DSequence ViewContactOfE3dScene::createViewIndependentPrimitive2DSequence() const +{ + drawinglayer::primitive2d::Primitive2DSequence xRetval; - // always append an invisible outline for the cases where no visible content exists - drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, - drawinglayer::primitive2d::createHiddenGeometryPrimitives2D( - false, getObjectTransformation())); + if(GetObjectCount()) + { + // create a default ScenePrimitive2D (without visibility test of members) + xRetval = createScenePrimitive2DSequence(0); + } - return xRetval; - } + return xRetval; +} - drawinglayer::primitive2d::Primitive2DSequence ViewContactOfE3dScene::createViewIndependentPrimitive2DSequence() const - { - drawinglayer::primitive2d::Primitive2DSequence xRetval; +void ViewContactOfE3dScene::ActionChanged() +{ + // call parent + ViewContactOfSdrObj::ActionChanged(); - if(GetObjectCount()) - { - // create a default ScenePrimitive2D (without visibility test of members) - xRetval = createScenePrimitive2DSequence(0); - } + // mark locally cached values as invalid + maViewInformation3D = drawinglayer::geometry::ViewInformation3D(); + maObjectTransformation.identity(); + maSdrSceneAttribute = drawinglayer::attribute::SdrSceneAttribute(); + maSdrLightingAttribute = drawinglayer::attribute::SdrLightingAttribute(); +} - return xRetval; - } +const drawinglayer::geometry::ViewInformation3D& ViewContactOfE3dScene::getViewInformation3D() const +{ + if(maViewInformation3D.isDefault()) + { + // this version will create the content range on demand locally and thus is less + // performant than the other one. Since the information is buffered the planned + // behaviour is that the version with the given range is used initially. + basegfx::B3DRange aContentRange(getAllContentRange3D()); - void ViewContactOfE3dScene::ActionChanged() + if(aContentRange.isEmpty()) { - // call parent - ViewContactOfSdrObj::ActionChanged(); - - // mark locally cached values as invalid - maViewInformation3D = drawinglayer::geometry::ViewInformation3D(); - maObjectTransformation.identity(); - maSdrSceneAttribute = drawinglayer::attribute::SdrSceneAttribute(); - maSdrLightingAttribute = drawinglayer::attribute::SdrLightingAttribute(); + // empty scene, no 3d action should be necessary. Prepare some + // fallback size + OSL_FAIL("No need to get ViewInformation3D from an empty scene (!)"); + aContentRange.expand(basegfx::B3DPoint(-100.0, -100.0, -100.0)); + aContentRange.expand(basegfx::B3DPoint( 100.0, 100.0, 100.0)); } - const drawinglayer::geometry::ViewInformation3D& ViewContactOfE3dScene::getViewInformation3D() const - { - if(maViewInformation3D.isDefault()) - { - // this version will create the content range on demand locally and thus is less - // performant than the other one. Since the information is buffered the planned - // behaviour is that the version with the given range is used initially. - basegfx::B3DRange aContentRange(getAllContentRange3D()); - - if(aContentRange.isEmpty()) - { - // empty scene, no 3d action should be necessary. Prepare some - // fallback size - OSL_FAIL("No need to get ViewInformation3D from an empty scene (!)"); - aContentRange.expand(basegfx::B3DPoint(-100.0, -100.0, -100.0)); - aContentRange.expand(basegfx::B3DPoint( 100.0, 100.0, 100.0)); - } - - const_cast < ViewContactOfE3dScene* >(this)->createViewInformation3D(aContentRange); - } + const_cast < ViewContactOfE3dScene* >(this)->createViewInformation3D(aContentRange); + } - return maViewInformation3D; - } + return maViewInformation3D; +} - const drawinglayer::geometry::ViewInformation3D& ViewContactOfE3dScene::getViewInformation3D(const basegfx::B3DRange& rContentRange) const - { - if(maViewInformation3D.isDefault()) - { - const_cast < ViewContactOfE3dScene* >(this)->createViewInformation3D(rContentRange); - } +const drawinglayer::geometry::ViewInformation3D& ViewContactOfE3dScene::getViewInformation3D(const basegfx::B3DRange& rContentRange) const +{ + if(maViewInformation3D.isDefault()) + { + const_cast < ViewContactOfE3dScene* >(this)->createViewInformation3D(rContentRange); + } - return maViewInformation3D; - } + return maViewInformation3D; +} - const basegfx::B2DHomMatrix& ViewContactOfE3dScene::getObjectTransformation() const - { - if(maObjectTransformation.isIdentity()) - { - const_cast < ViewContactOfE3dScene* >(this)->createObjectTransformation(); - } +const basegfx::B2DHomMatrix& ViewContactOfE3dScene::getObjectTransformation() const +{ + if(maObjectTransformation.isIdentity()) + { + const_cast < ViewContactOfE3dScene* >(this)->createObjectTransformation(); + } - return maObjectTransformation; - } + return maObjectTransformation; +} - const drawinglayer::attribute::SdrSceneAttribute& ViewContactOfE3dScene::getSdrSceneAttribute() const - { - if(maSdrSceneAttribute.isDefault()) - { - const_cast < ViewContactOfE3dScene* >(this)->createSdrSceneAttribute(); - } +const drawinglayer::attribute::SdrSceneAttribute& ViewContactOfE3dScene::getSdrSceneAttribute() const +{ + if(maSdrSceneAttribute.isDefault()) + { + const_cast < ViewContactOfE3dScene* >(this)->createSdrSceneAttribute(); + } - return maSdrSceneAttribute; - } + return maSdrSceneAttribute; +} - const drawinglayer::attribute::SdrLightingAttribute& ViewContactOfE3dScene::getSdrLightingAttribute() const - { - if(maSdrLightingAttribute.isDefault()) - { - const_cast < ViewContactOfE3dScene* >(this)->createSdrLightingAttribute(); - } +const drawinglayer::attribute::SdrLightingAttribute& ViewContactOfE3dScene::getSdrLightingAttribute() const +{ + if(maSdrLightingAttribute.isDefault()) + { + const_cast < ViewContactOfE3dScene* >(this)->createSdrLightingAttribute(); + } - return maSdrLightingAttribute; - } + return maSdrLightingAttribute; +} - drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3dScene::getAllPrimitive3DSequence() const - { - drawinglayer::primitive3d::Primitive3DSequence aAllPrimitive3DSequence; - const sal_uInt32 nChildrenCount(GetObjectCount()); +drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3dScene::getAllPrimitive3DSequence() const +{ + drawinglayer::primitive3d::Primitive3DSequence aAllPrimitive3DSequence; + const sal_uInt32 nChildrenCount(GetObjectCount()); + + // add children recursively. Do NOT start with (*this), this would create + // a 3D transformPrimitive for the start scene. While this is theoretically not + // a bad thing, for historical reasons the transformation of the outmost scene + // is seen as part of the ViewTransformation (see text in createViewInformation3D) + for(sal_uInt32 a(0L); a < nChildrenCount; a++) + { + createSubPrimitive3DVector(GetViewContact(a), aAllPrimitive3DSequence, 0, 0, false); + } - // add children recursively. Do NOT start with (*this), this would create - // a 3D transformPrimitive for the start scene. While this is theoretically not - // a bad thing, for historical reasons the transformation of the outmost scene - // is seen as part of the ViewTransformation (see text in createViewInformation3D) - for(sal_uInt32 a(0L); a < nChildrenCount; a++) - { - createSubPrimitive3DVector(GetViewContact(a), aAllPrimitive3DSequence, 0, 0, false); - } + return aAllPrimitive3DSequence; +} - return aAllPrimitive3DSequence; - } +basegfx::B3DRange ViewContactOfE3dScene::getAllContentRange3D() const +{ + const drawinglayer::primitive3d::Primitive3DSequence xAllSequence(getAllPrimitive3DSequence()); + basegfx::B3DRange aAllContentRange3D; - basegfx::B3DRange ViewContactOfE3dScene::getAllContentRange3D() const - { - const drawinglayer::primitive3d::Primitive3DSequence xAllSequence(getAllPrimitive3DSequence()); - basegfx::B3DRange aAllContentRange3D; + if(xAllSequence.hasElements()) + { + // for getting the 3D range using getB3DRangeFromPrimitive3DSequence a ViewInformation3D + // needs to be given for evtl. decompositions. Use a neutral ViewInformation3D here. This + // leaves all matrices on identity and the time on 0.0. + const uno::Sequence< beans::PropertyValue > aEmptyProperties; + const drawinglayer::geometry::ViewInformation3D aNeutralViewInformation3D(aEmptyProperties); - if(xAllSequence.hasElements()) - { - // for getting the 3D range using getB3DRangeFromPrimitive3DSequence a ViewInformation3D - // needs to be given for evtl. decompositions. Use a neutral ViewInformation3D here. This - // leaves all matrices on identity and the time on 0.0. - const uno::Sequence< beans::PropertyValue > aEmptyProperties; - const drawinglayer::geometry::ViewInformation3D aNeutralViewInformation3D(aEmptyProperties); + aAllContentRange3D = drawinglayer::primitive3d::getB3DRangeFromPrimitive3DSequence(xAllSequence, aNeutralViewInformation3D); + } - aAllContentRange3D = drawinglayer::primitive3d::getB3DRangeFromPrimitive3DSequence(xAllSequence, aNeutralViewInformation3D); - } + return aAllContentRange3D; +} - return aAllContentRange3D; - } - } // end of namespace contact -} // end of namespace sdr +}} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/contact/viewcontactofpageobj.cxx b/svx/source/sdr/contact/viewcontactofpageobj.cxx index ec7ae8eca5ca..4e5614d6d7c6 100644 --- a/svx/source/sdr/contact/viewcontactofpageobj.cxx +++ b/svx/source/sdr/contact/viewcontactofpageobj.cxx @@ -29,60 +29,55 @@ #include <basegfx/polygon/b2dpolygontools.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +namespace sdr { namespace contact { - -namespace sdr +ViewObjectContact& ViewContactOfPageObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) { - namespace contact - { - ViewObjectContact& ViewContactOfPageObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) - { - ViewObjectContact* pRetval = new ViewObjectContactOfPageObj(rObjectContact, *this); - return *pRetval; - } + ViewObjectContact* pRetval = new ViewObjectContactOfPageObj(rObjectContact, *this); + return *pRetval; +} - ViewContactOfPageObj::ViewContactOfPageObj(SdrPageObj& rPageObj) - : ViewContactOfSdrObj(rPageObj) - { - } +ViewContactOfPageObj::ViewContactOfPageObj(SdrPageObj& rPageObj) +: ViewContactOfSdrObj(rPageObj) +{ +} - ViewContactOfPageObj::~ViewContactOfPageObj() - { - } +ViewContactOfPageObj::~ViewContactOfPageObj() +{ +} - // #i35972# React on changes of the object of this ViewContact - void ViewContactOfPageObj::ActionChanged() - { - static bool bIsInActionChange(false); +// #i35972# React on changes of the object of this ViewContact +void ViewContactOfPageObj::ActionChanged() +{ + static bool bIsInActionChange(false); - if(!bIsInActionChange) - { - // set recursion flag, see description in *.hxx - bIsInActionChange = true; + if(!bIsInActionChange) + { + // set recursion flag, see description in *.hxx + bIsInActionChange = true; - // call parent - ViewContactOfSdrObj::ActionChanged(); + // call parent + ViewContactOfSdrObj::ActionChanged(); - // reset recursion flag, see description in *.hxx - bIsInActionChange = false; - } - } + // reset recursion flag, see description in *.hxx + bIsInActionChange = false; + } +} - drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageObj::createViewIndependentPrimitive2DSequence() const - { - // ceate graphical visualisation data. Since this is the view-independent version which should not be used, - // create a replacement graphic visualisation here. Use GetLastBoundRect to access the model data directly - // which is aOutRect for SdrPageObj. - const Rectangle aModelRectangle(GetPageObj().GetLastBoundRect()); - const basegfx::B2DRange aModelRange(aModelRectangle.Left(), aModelRectangle.Top(), aModelRectangle.Right(), aModelRectangle.Bottom()); - const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aModelRange)); - const basegfx::BColor aYellow(1.0, 1.0, 0.0); - const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aOutline, aYellow)); +drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageObj::createViewIndependentPrimitive2DSequence() const +{ + // ceate graphical visualisation data. Since this is the view-independent version which should not be used, + // create a replacement graphic visualisation here. Use GetLastBoundRect to access the model data directly + // which is aOutRect for SdrPageObj. + const Rectangle aModelRectangle(GetPageObj().GetLastBoundRect()); + const basegfx::B2DRange aModelRange(aModelRectangle.Left(), aModelRectangle.Top(), aModelRectangle.Right(), aModelRectangle.Bottom()); + const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aModelRange)); + const basegfx::BColor aYellow(1.0, 1.0, 0.0); + const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aOutline, aYellow)); - return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); - } + return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); +} - } // end of namespace contact -} // end of namespace sdr +}} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx b/svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx index 75460eca4a3b..214a871b14d1 100644 --- a/svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx @@ -26,30 +26,20 @@ namespace sdr { namespace contact { - -// - ViewContactOfSdrMediaObj - - - ViewContactOfSdrMediaObj::ViewContactOfSdrMediaObj( SdrMediaObj& rMediaObj ) : ViewContactOfSdrObj( rMediaObj ) { } - - ViewContactOfSdrMediaObj::~ViewContactOfSdrMediaObj() { } - - ViewObjectContact& ViewContactOfSdrMediaObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) { return *( new ViewObjectContactOfSdrMediaObj( rObjectContact, *this, static_cast< SdrMediaObj& >( GetSdrObject() ).getMediaProperties() ) ); } - - Size ViewContactOfSdrMediaObj::getPreferredSize() const { // #i71805# Since we may have a whole bunch of VOCs here, make a loop @@ -70,8 +60,6 @@ Size ViewContactOfSdrMediaObj::getPreferredSize() const return Size(); } - - void ViewContactOfSdrMediaObj::updateMediaItem( ::avmedia::MediaItem& rItem ) const { // #i71805# Since we may have a whole bunch of VOCs here, make a loop @@ -88,8 +76,6 @@ void ViewContactOfSdrMediaObj::updateMediaItem( ::avmedia::MediaItem& rItem ) co } } - - void ViewContactOfSdrMediaObj::executeMediaItem( const ::avmedia::MediaItem& rItem ) { const sal_uInt32 nCount(getViewObjectContactCount()); @@ -105,53 +91,45 @@ void ViewContactOfSdrMediaObj::executeMediaItem( const ::avmedia::MediaItem& rIt } } - - void ViewContactOfSdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewState ) { static_cast< SdrMediaObj& >(GetSdrObject()).mediaPropertiesChanged(rNewState); } -}} // end of namespace sdr::contact - -namespace sdr +drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrMediaObj::createViewIndependentPrimitive2DSequence() const { - namespace contact - { - drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrMediaObj::createViewIndependentPrimitive2DSequence() const - { - // create range using the model data directly. This is in SdrTextObj::aRect which i will access using - // GetGeoRect() to not trigger any calculations. It's the unrotated geometry which is okay for MediaObjects ATM. - Rectangle aRectangle(GetSdrMediaObj().GetGeoRect()); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - aRectangle += GetSdrMediaObj().GetGridOffset(); - const basegfx::B2DRange aRange( - aRectangle.Left(), aRectangle.Top(), - aRectangle.Right(), aRectangle.Bottom()); - - // create object transform - basegfx::B2DHomMatrix aTransform; - aTransform.set(0, 0, aRange.getWidth()); - aTransform.set(1, 1, aRange.getHeight()); - aTransform.set(0, 2, aRange.getMinX()); - aTransform.set(1, 2, aRange.getMinY()); - - // create media primitive. Always create primitives to allow the - // decomposition of MediaPrimitive2D to create needed invisible elements for HitTest - // and/or BoundRect - const basegfx::BColor aBackgroundColor(67.0 / 255.0, 67.0 / 255.0, 67.0 / 255.0); - const OUString& rURL(GetSdrMediaObj().getURL()); - const sal_uInt32 nPixelBorder(4L); - const drawinglayer::primitive2d::Primitive2DReference xRetval( - new drawinglayer::primitive2d::MediaPrimitive2D( - aTransform, rURL, aBackgroundColor, nPixelBorder, - GetSdrMediaObj().getSnapshot())); - - return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1); - } - } // end of namespace contact -} // end of namespace sdr + // create range using the model data directly. This is in SdrTextObj::aRect which i will access using + // GetGeoRect() to not trigger any calculations. It's the unrotated geometry which is okay for MediaObjects ATM. + Rectangle aRectangle(GetSdrMediaObj().GetGeoRect()); + // Hack for calc, transform position of object according + // to current zoom so as objects relative position to grid + // appears stable + aRectangle += GetSdrMediaObj().GetGridOffset(); + const basegfx::B2DRange aRange( + aRectangle.Left(), aRectangle.Top(), + aRectangle.Right(), aRectangle.Bottom()); + + // create object transform + basegfx::B2DHomMatrix aTransform; + aTransform.set(0, 0, aRange.getWidth()); + aTransform.set(1, 1, aRange.getHeight()); + aTransform.set(0, 2, aRange.getMinX()); + aTransform.set(1, 2, aRange.getMinY()); + + // create media primitive. Always create primitives to allow the + // decomposition of MediaPrimitive2D to create needed invisible elements for HitTest + // and/or BoundRect + const basegfx::BColor aBackgroundColor(67.0 / 255.0, 67.0 / 255.0, 67.0 / 255.0); + const OUString& rURL(GetSdrMediaObj().getURL()); + const sal_uInt32 nPixelBorder(4L); + const drawinglayer::primitive2d::Primitive2DReference xRetval( + new drawinglayer::primitive2d::MediaPrimitive2D( + aTransform, rURL, aBackgroundColor, nPixelBorder, + GetSdrMediaObj().getSnapshot())); + + return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1); +} + +}} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx b/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx index a1c2e1bd8636..80ded95ec15a 100644 --- a/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - #include <svx/sdr/contact/viewcontactofsdrrectobj.hxx> #include <svx/svdorect.hxx> #include <svx/sdr/primitive2d/sdrattributecreator.hxx> @@ -27,73 +26,69 @@ #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <svx/svdmodel.hxx> +namespace sdr { namespace contact { +ViewContactOfSdrRectObj::ViewContactOfSdrRectObj(SdrRectObj& rRectObj) +: ViewContactOfTextObj(rRectObj) +{ +} -namespace sdr +ViewContactOfSdrRectObj::~ViewContactOfSdrRectObj() { - namespace contact - { - ViewContactOfSdrRectObj::ViewContactOfSdrRectObj(SdrRectObj& rRectObj) - : ViewContactOfTextObj(rRectObj) - { - } +} - ViewContactOfSdrRectObj::~ViewContactOfSdrRectObj() - { - } +drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrRectObj::createViewIndependentPrimitive2DSequence() const +{ + const SfxItemSet& rItemSet = GetRectObj().GetMergedItemSet(); + const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute( + drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute( + rItemSet, + GetRectObj().getText(0), + false)); - drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrRectObj::createViewIndependentPrimitive2DSequence() const - { - const SfxItemSet& rItemSet = GetRectObj().GetMergedItemSet(); - const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute( - drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute( - rItemSet, - GetRectObj().getText(0), - false)); + // take unrotated snap rect (direct model data) for position and size + Rectangle rRectangle = GetRectObj().GetGeoRect(); + // Hack for calc, transform position of object according + // to current zoom so as objects relative position to grid + // appears stable + rRectangle += GetRectObj().GetGridOffset(); + const ::basegfx::B2DRange aObjectRange( + rRectangle.Left(), rRectangle.Top(), + rRectangle.Right(), rRectangle.Bottom() ); - // take unrotated snap rect (direct model data) for position and size - Rectangle rRectangle = GetRectObj().GetGeoRect(); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - rRectangle += GetRectObj().GetGridOffset(); - const ::basegfx::B2DRange aObjectRange( - rRectangle.Left(), rRectangle.Top(), - rRectangle.Right(), rRectangle.Bottom() ); + const GeoStat& rGeoStat(GetRectObj().GetGeoStat()); - const GeoStat& rGeoStat(GetRectObj().GetGeoStat()); + // fill object matrix + basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + aObjectRange.getWidth(), aObjectRange.getHeight(), + rGeoStat.nShearAngle ? tan((36000 - rGeoStat.nShearAngle) * F_PI18000) : 0.0, + rGeoStat.nRotationAngle ? (36000 - rGeoStat.nRotationAngle) * F_PI18000 : 0.0, + aObjectRange.getMinX(), aObjectRange.getMinY())); - // fill object matrix - basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( - aObjectRange.getWidth(), aObjectRange.getHeight(), - rGeoStat.nShearAngle ? tan((36000 - rGeoStat.nShearAngle) * F_PI18000) : 0.0, - rGeoStat.nRotationAngle ? (36000 - rGeoStat.nRotationAngle) * F_PI18000 : 0.0, - aObjectRange.getMinX(), aObjectRange.getMinY())); + // calculate corner radius + sal_uInt32 nCornerRadius((static_cast<const SdrMetricItem&>(rItemSet.Get(SDRATTR_ECKENRADIUS))).GetValue()); + double fCornerRadiusX; + double fCornerRadiusY; + drawinglayer::primitive2d::calculateRelativeCornerRadius(nCornerRadius, aObjectRange, fCornerRadiusX, fCornerRadiusY); - // calculate corner radius - sal_uInt32 nCornerRadius((static_cast<const SdrMetricItem&>(rItemSet.Get(SDRATTR_ECKENRADIUS))).GetValue()); - double fCornerRadiusX; - double fCornerRadiusY; - drawinglayer::primitive2d::calculateRelativeCornerRadius(nCornerRadius, aObjectRange, fCornerRadiusX, fCornerRadiusY); + // #i105856# use knowledge about pickthrough from the model + const bool bPickThroughTransparentTextFrames( + GetRectObj().GetModel() && GetRectObj().GetModel()->IsPickThroughTransparentTextFrames()); - // #i105856# use knowledge about pickthrough from the model - const bool bPickThroughTransparentTextFrames( - GetRectObj().GetModel() && GetRectObj().GetModel()->IsPickThroughTransparentTextFrames()); + // create primitive. Always create primitives to allow the decomposition of + // SdrRectanglePrimitive2D to create needed invisible elements for HitTest and/or BoundRect + const drawinglayer::primitive2d::Primitive2DReference xReference( + new drawinglayer::primitive2d::SdrRectanglePrimitive2D( + aObjectMatrix, + aAttribute, + fCornerRadiusX, + fCornerRadiusY, + // #i105856# use fill for HitTest when TextFrame and not PickThrough + GetRectObj().IsTextFrame() && !bPickThroughTransparentTextFrames)); - // create primitive. Always create primitives to allow the decomposition of - // SdrRectanglePrimitive2D to create needed invisible elements for HitTest and/or BoundRect - const drawinglayer::primitive2d::Primitive2DReference xReference( - new drawinglayer::primitive2d::SdrRectanglePrimitive2D( - aObjectMatrix, - aAttribute, - fCornerRadiusX, - fCornerRadiusY, - // #i105856# use fill for HitTest when TextFrame and not PickThrough - GetRectObj().IsTextFrame() && !bPickThroughTransparentTextFrames)); + return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); +} - return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); - } - } // end of namespace contact -} // end of namespace sdr +}} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/contact/viewcontactoftextobj.cxx b/svx/source/sdr/contact/viewcontactoftextobj.cxx index e35c3bdf51af..7b6913b3198f 100644 --- a/svx/source/sdr/contact/viewcontactoftextobj.cxx +++ b/svx/source/sdr/contact/viewcontactoftextobj.cxx @@ -20,21 +20,22 @@ #include <svx/sdr/contact/viewcontactoftextobj.hxx> #include <svx/svdotext.hxx> +namespace sdr { namespace contact { +const SdrTextObj& ViewContactOfTextObj::GetTextObj() const +{ + return static_cast<const SdrTextObj&>(GetSdrObject()); +} + +ViewContactOfTextObj::ViewContactOfTextObj(SdrTextObj& rTextObj) +: ViewContactOfSdrObj(rTextObj) +{ +} -namespace sdr +ViewContactOfTextObj::~ViewContactOfTextObj() { - namespace contact - { - ViewContactOfTextObj::ViewContactOfTextObj(SdrTextObj& rTextObj) - : ViewContactOfSdrObj(rTextObj) - { - } +} - ViewContactOfTextObj::~ViewContactOfTextObj() - { - } - } // end of namespace contact -} // end of namespace sdr +}} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/contact/viewcontactofvirtobj.cxx b/svx/source/sdr/contact/viewcontactofvirtobj.cxx index e75a2dcfb1ca..90997fe7bfa1 100644 --- a/svx/source/sdr/contact/viewcontactofvirtobj.cxx +++ b/svx/source/sdr/contact/viewcontactofvirtobj.cxx @@ -25,81 +25,78 @@ #include <vcl/outdev.hxx> #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx> +namespace sdr { namespace contact { +ViewContactOfVirtObj::ViewContactOfVirtObj(SdrVirtObj& rObj) +: ViewContactOfSdrObj(rObj) +{ +} + +ViewContactOfVirtObj::~ViewContactOfVirtObj() +{ +} -namespace sdr +SdrVirtObj& ViewContactOfVirtObj::GetVirtObj() const { - namespace contact + return static_cast<SdrVirtObj&>(mrObject); +} + +// Access to possible sub-hierarchy +sal_uInt32 ViewContactOfVirtObj::GetObjectCount() const +{ + // Here, SdrVirtObj's need to return 0L to show that they have no + // sub-hierarchy, even when they are group objects. This is necessary + // to avoid that the same VOCs will be added to the draw hierarchy + // twice which leads to problems. + + // This solution is only a first solution to get things running. Later + // this needs to be replaced with creating real VOCs for the objects + // referenced by virtual objects to avoid the 'trick' of setting the + // offset for painting at the destination OutputDevive. + + // As can be seen, with primitives, the problem will be solved using + // a transformPrimitive, so this solution can stay with primitives. + return 0L; +} + +drawinglayer::primitive2d::Primitive2DSequence ViewContactOfVirtObj::createViewIndependentPrimitive2DSequence() const +{ + // create displacement transformation if we have content + basegfx::B2DHomMatrix aObjectMatrix; + Point aAnchor(GetVirtObj().GetAnchorPos()); + + if(aAnchor.X() || aAnchor.Y()) { - ViewContactOfVirtObj::ViewContactOfVirtObj(SdrVirtObj& rObj) - : ViewContactOfSdrObj(rObj) - { - } - - ViewContactOfVirtObj::~ViewContactOfVirtObj() - { - } - - SdrVirtObj& ViewContactOfVirtObj::GetVirtObj() const - { - return static_cast<SdrVirtObj&>(mrObject); - } - - // Access to possible sub-hierarchy - sal_uInt32 ViewContactOfVirtObj::GetObjectCount() const - { - // Here, SdrVirtObj's need to return 0L to show that they have no - // sub-hierarchy, even when they are group objects. This is necessary - // to avoid that the same VOCs will be added to the draw hierarchy - // twice which leads to problems. - - // This solution is only a first solution to get things running. Later - // this needs to be replaced with creating real VOCs for the objects - // referenced by virtual objects to avoid the 'trick' of setting the - // offset for painting at the destination OutputDevive. - - // As can be seen, with primitives, the problem will be solved using - // a transformPrimitive, so this solution can stay with primitives. - return 0L; - } - - drawinglayer::primitive2d::Primitive2DSequence ViewContactOfVirtObj::createViewIndependentPrimitive2DSequence() const - { - // create displacement transformation if we have content - basegfx::B2DHomMatrix aObjectMatrix; - Point aAnchor(GetVirtObj().GetAnchorPos()); - - if(aAnchor.X() || aAnchor.Y()) - { - aObjectMatrix.set(0, 2, aAnchor.X()); - aObjectMatrix.set(1, 2, aAnchor.Y()); - } - - // use method from referenced object to get the Primitive2DSequence - const drawinglayer::primitive2d::Primitive2DSequence xSequenceVirtual( - GetVirtObj().GetReferencedObj().GetViewContact().getViewIndependentPrimitive2DSequence()); - - if(xSequenceVirtual.hasElements()) - { - // create transform primitive - const drawinglayer::primitive2d::Primitive2DReference xReference( - new drawinglayer::primitive2d::TransformPrimitive2D( - aObjectMatrix, - xSequenceVirtual)); - - return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); - } - else - { - // always append an invisible outline for the cases where no visible content exists - const drawinglayer::primitive2d::Primitive2DReference xReference( - drawinglayer::primitive2d::createHiddenGeometryPrimitives2D( - false, aObjectMatrix)); - - return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); - } - } - } // end of namespace contact -} // end of namespace sdr + aObjectMatrix.set(0, 2, aAnchor.X()); + aObjectMatrix.set(1, 2, aAnchor.Y()); + } + + // use method from referenced object to get the Primitive2DSequence + const drawinglayer::primitive2d::Primitive2DSequence xSequenceVirtual( + GetVirtObj().GetReferencedObj().GetViewContact().getViewIndependentPrimitive2DSequence()); + + if(xSequenceVirtual.hasElements()) + { + // create transform primitive + const drawinglayer::primitive2d::Primitive2DReference xReference( + new drawinglayer::primitive2d::TransformPrimitive2D( + aObjectMatrix, + xSequenceVirtual)); + + return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); + } + else + { + // always append an invisible outline for the cases where no visible content exists + const drawinglayer::primitive2d::Primitive2DReference xReference( + drawinglayer::primitive2d::createHiddenGeometryPrimitives2D( + false, aObjectMatrix)); + + return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); + } +} + +}} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + diff --git a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx index b5b9f01b37f5..8e65fb02a58f 100644 --- a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx @@ -17,13 +17,11 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - -#include <svtools/colorcfg.hxx> - #include <svx/sdr/contact/viewobjectcontactofpageobj.hxx> #include <svx/sdr/contact/viewcontactofpageobj.hxx> #include <svx/svdopage.hxx> #include <svx/sdr/contact/displayinfo.hxx> +#include <svtools/colorcfg.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> @@ -34,310 +32,296 @@ #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx> #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx> +using namespace com::sun::star; +namespace sdr { namespace contact { -using namespace com::sun::star; +class PagePrimitiveExtractor : public ObjectContactOfPagePainter, public Timer +{ +private: + // the ViewObjectContactOfPageObj using this painter + ViewObjectContactOfPageObj& mrViewObjectContactOfPageObj; + +public: + // basic constructor/destructor + explicit PagePrimitiveExtractor(ViewObjectContactOfPageObj& rVOC); + virtual ~PagePrimitiveExtractor(); + + // LazyInvalidate request. Supported here to not automatically + // invalidate the second interaction state all the time at the + // original OC + virtual void setLazyInvalidate(ViewObjectContact& rVOC) SAL_OVERRIDE; + + // From baseclass Timer, the timeout call triggered by the LazyInvalidate mechanism + virtual void Timeout() SAL_OVERRIDE; + + // get primitive visualization + drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceForPage(const DisplayInfo& rDisplayInfo); + + // Own reaction on changes which will be forwarded to the OC of the owner-VOC + virtual void InvalidatePartOfView(const basegfx::B2DRange& rRange) const SAL_OVERRIDE; + + // forward access to SdrPageView of ViewObjectContactOfPageObj + virtual bool isOutputToPrinter() const SAL_OVERRIDE; + virtual bool isOutputToWindow() const SAL_OVERRIDE; + virtual bool isOutputToVirtualDevice() const SAL_OVERRIDE; + virtual bool isOutputToRecordingMetaFile() const SAL_OVERRIDE; + virtual bool isOutputToPDFFile() const SAL_OVERRIDE; + virtual bool isDrawModeGray() const SAL_OVERRIDE; + virtual bool isDrawModeBlackWhite() const SAL_OVERRIDE; + virtual bool isDrawModeHighContrast() const SAL_OVERRIDE; + virtual SdrPageView* TryToGetSdrPageView() const SAL_OVERRIDE; + virtual OutputDevice* TryToGetOutputDevice() const SAL_OVERRIDE; +}; + +PagePrimitiveExtractor::PagePrimitiveExtractor( + ViewObjectContactOfPageObj& rVOC) +: ObjectContactOfPagePainter(0, rVOC.GetObjectContact()), + mrViewObjectContactOfPageObj(rVOC) +{ + // make this renderer a preview renderer + setPreviewRenderer(true); + // init timer + SetTimeout(1); + Stop(); +} +PagePrimitiveExtractor::~PagePrimitiveExtractor() +{ + // execute missing LazyInvalidates and stop timer + Timeout(); +} + +void PagePrimitiveExtractor::setLazyInvalidate(ViewObjectContact& /*rVOC*/) +{ + // do NOT call parent, but remember that something is to do by + // starting the LazyInvalidateTimer + Start(); +} -namespace sdr +// From baseclass Timer, the timeout call triggered by the LazyInvalidate mechanism +void PagePrimitiveExtractor::Timeout() { - namespace contact + // stop the timer + Stop(); + + // invalidate all LazyInvalidate VOCs new situations + const sal_uInt32 nVOCCount(getViewObjectContactCount()); + + for(sal_uInt32 a(0); a < nVOCCount; a++) { - class PagePrimitiveExtractor : public ObjectContactOfPagePainter, public Timer - { - private: - // the ViewObjectContactOfPageObj using this painter - ViewObjectContactOfPageObj& mrViewObjectContactOfPageObj; - - public: - // basic constructor/destructor - explicit PagePrimitiveExtractor(ViewObjectContactOfPageObj& rVOC); - virtual ~PagePrimitiveExtractor(); - - // LazyInvalidate request. Supported here to not automatically - // invalidate the second interaction state all the time at the - // original OC - virtual void setLazyInvalidate(ViewObjectContact& rVOC) SAL_OVERRIDE; - - // From baseclass Timer, the timeout call triggered by the LazyInvalidate mechanism - virtual void Timeout() SAL_OVERRIDE; - - // get primitive visualization - drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceForPage(const DisplayInfo& rDisplayInfo); - - // Own reaction on changes which will be forwarded to the OC of the owner-VOC - virtual void InvalidatePartOfView(const basegfx::B2DRange& rRange) const SAL_OVERRIDE; - - // forward access to SdrPageView of ViewObjectContactOfPageObj - virtual bool isOutputToPrinter() const SAL_OVERRIDE; - virtual bool isOutputToWindow() const SAL_OVERRIDE; - virtual bool isOutputToVirtualDevice() const SAL_OVERRIDE; - virtual bool isOutputToRecordingMetaFile() const SAL_OVERRIDE; - virtual bool isOutputToPDFFile() const SAL_OVERRIDE; - virtual bool isDrawModeGray() const SAL_OVERRIDE; - virtual bool isDrawModeBlackWhite() const SAL_OVERRIDE; - virtual bool isDrawModeHighContrast() const SAL_OVERRIDE; - virtual SdrPageView* TryToGetSdrPageView() const SAL_OVERRIDE; - virtual OutputDevice* TryToGetOutputDevice() const SAL_OVERRIDE; - }; - - PagePrimitiveExtractor::PagePrimitiveExtractor( - ViewObjectContactOfPageObj& rVOC) - : ObjectContactOfPagePainter(0, rVOC.GetObjectContact()), - mrViewObjectContactOfPageObj(rVOC) - { - // make this renderer a preview renderer - setPreviewRenderer(true); + ViewObjectContact* pCandidate = getViewObjectContact(a); + pCandidate->triggerLazyInvalidate(); + } +} - // init timer - SetTimeout(1); - Stop(); - } +drawinglayer::primitive2d::Primitive2DSequence PagePrimitiveExtractor::createPrimitive2DSequenceForPage(const DisplayInfo& /*rDisplayInfo*/) +{ + drawinglayer::primitive2d::Primitive2DSequence xRetval; + const SdrPage* pStartPage = GetStartPage(); + + if(pStartPage) + { + // update own ViewInformation2D for visualized page + const drawinglayer::geometry::ViewInformation2D& rOriginalViewInformation = mrViewObjectContactOfPageObj.GetObjectContact().getViewInformation2D(); + const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D( + rOriginalViewInformation.getObjectTransformation(), + rOriginalViewInformation.getViewTransformation(), + + // #i101075# use empty range for page content here to force + // the content not to be physically clipped in any way. This + // would be possible, but would require the internal transformation + // which maps between the page visualisation object and the page + // content, including the aspect ratios (for details see in + // PagePreviewPrimitive2D::create2DDecomposition) + basegfx::B2DRange(), + + GetXDrawPageForSdrPage(const_cast< SdrPage* >(pStartPage)), + 0.0, // no time; page previews are not animated + rOriginalViewInformation.getExtendedInformationSequence()); + updateViewInformation2D(aNewViewInformation2D); + + // create copy of DisplayInfo to set PagePainting + DisplayInfo aDisplayInfo; + + // get page's VOC + ViewObjectContact& rDrawPageVOContact = pStartPage->GetViewContact().GetViewObjectContact(*this); + + // get whole Primitive2DSequence + xRetval = rDrawPageVOContact.getPrimitive2DSequenceHierarchy(aDisplayInfo); + } + + return xRetval; +} + +void PagePrimitiveExtractor::InvalidatePartOfView(const basegfx::B2DRange& rRange) const +{ + // an invalidate is called at this view, this needs to be translated to an invalidate + // for the using VOC. Coordinates are in page coordinate system. + const SdrPage* pStartPage = GetStartPage(); + + if(pStartPage && !rRange.isEmpty()) + { + const basegfx::B2DRange aPageRange(0.0, 0.0, (double)pStartPage->GetWdt(), (double)pStartPage->GetHgt()); - PagePrimitiveExtractor::~PagePrimitiveExtractor() + if(rRange.overlaps(aPageRange)) { - // execute missing LazyInvalidates and stop timer - Timeout(); + // if object on the page is inside or overlapping with page, create ActionChanged() for + // involved VOC + mrViewObjectContactOfPageObj.ActionChanged(); } + } +} + +// forward access to SdrPageView to VOCOfPageObj +bool PagePrimitiveExtractor::isOutputToPrinter() const { return mrViewObjectContactOfPageObj.GetObjectContact().isOutputToPrinter(); } +bool PagePrimitiveExtractor::isOutputToWindow() const { return mrViewObjectContactOfPageObj.GetObjectContact().isOutputToWindow(); } +bool PagePrimitiveExtractor::isOutputToVirtualDevice() const { return mrViewObjectContactOfPageObj.GetObjectContact().isOutputToVirtualDevice(); } +bool PagePrimitiveExtractor::isOutputToRecordingMetaFile() const { return mrViewObjectContactOfPageObj.GetObjectContact().isOutputToRecordingMetaFile(); } +bool PagePrimitiveExtractor::isOutputToPDFFile() const { return mrViewObjectContactOfPageObj.GetObjectContact().isOutputToPDFFile(); } +bool PagePrimitiveExtractor::isDrawModeGray() const { return mrViewObjectContactOfPageObj.GetObjectContact().isDrawModeGray(); } +bool PagePrimitiveExtractor::isDrawModeBlackWhite() const { return mrViewObjectContactOfPageObj.GetObjectContact().isDrawModeBlackWhite(); } +bool PagePrimitiveExtractor::isDrawModeHighContrast() const { return mrViewObjectContactOfPageObj.GetObjectContact().isDrawModeHighContrast(); } +SdrPageView* PagePrimitiveExtractor::TryToGetSdrPageView() const { return mrViewObjectContactOfPageObj.GetObjectContact().TryToGetSdrPageView(); } +OutputDevice* PagePrimitiveExtractor::TryToGetOutputDevice() const { return mrViewObjectContactOfPageObj.GetObjectContact().TryToGetOutputDevice(); } + +drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfPageObj::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const +{ + drawinglayer::primitive2d::Primitive2DSequence xRetval; + const SdrPageObj& rPageObject((static_cast< ViewContactOfPageObj& >(GetViewContact())).GetPageObj()); + const SdrPage* pPage = rPageObject.GetReferencedPage(); + const svtools::ColorConfig aColorConfig; - void PagePrimitiveExtractor::setLazyInvalidate(ViewObjectContact& /*rVOC*/) + // get PageObject's geometry + basegfx::B2DHomMatrix aPageObjectTransform; + { + const Rectangle aPageObjectModelData(rPageObject.GetLastBoundRect()); + const basegfx::B2DRange aPageObjectBound( + aPageObjectModelData.Left(), aPageObjectModelData.Top(), + aPageObjectModelData.Right(), aPageObjectModelData.Bottom()); + + aPageObjectTransform.set(0, 0, aPageObjectBound.getWidth()); + aPageObjectTransform.set(1, 1, aPageObjectBound.getHeight()); + aPageObjectTransform.set(0, 2, aPageObjectBound.getMinX()); + aPageObjectTransform.set(1, 2, aPageObjectBound.getMinY()); + } + + // #i102637# add gray frame also when printing and page exists (handout pages) + const bool bCreateGrayFrame(!GetObjectContact().isOutputToPrinter() || pPage); + + // get displayed page's content. This is the uscaled page content + if(mpExtractor && pPage) + { + // get displayed page's geometry + drawinglayer::primitive2d::Primitive2DSequence xPageContent; + const Size aPageSize(pPage->GetSize()); + const double fPageWidth(aPageSize.getWidth()); + const double fPageHeight(aPageSize.getHeight()); + + // The case that a PageObject contains another PageObject which visualizes the + // same page again would lead to a recursion. Limit that recursion depth to one + // by using a local static bool + static bool bInCreatePrimitive2D(false); + + if(bInCreatePrimitive2D) { - // do NOT call parent, but remember that something is to do by - // starting the LazyInvalidateTimer - Start(); + // Recursion is possible. Create a replacement primitive + xPageContent.realloc(2); + const Color aDocColor(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor); + const Color aBorderColor(aColorConfig.GetColorValue(svtools::DOCBOUNDARIES).nColor); + const basegfx::B2DRange aPageBound(0.0, 0.0, fPageWidth, fPageHeight); + const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aPageBound)); + + // add replacement fill + xPageContent[0L] = drawinglayer::primitive2d::Primitive2DReference( + new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aOutline), aDocColor.getBColor())); + + // add replacement border + xPageContent[1L] = drawinglayer::primitive2d::Primitive2DReference( + new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aOutline, aBorderColor.getBColor())); } - - // From baseclass Timer, the timeout call triggered by the LazyInvalidate mechanism - void PagePrimitiveExtractor::Timeout() + else { - // stop the timer - Stop(); + // set recursion flag + bInCreatePrimitive2D = true; - // invalidate all LazyInvalidate VOCs new situations - const sal_uInt32 nVOCCount(getViewObjectContactCount()); + // init extractor, guarantee existence, set page there + mpExtractor->SetStartPage(pPage); - for(sal_uInt32 a(0); a < nVOCCount; a++) - { - ViewObjectContact* pCandidate = getViewObjectContact(a); - pCandidate->triggerLazyInvalidate(); - } - } + // #i105548# also need to copy the VOCRedirector for sub-content creation + mpExtractor->SetViewObjectContactRedirector(GetObjectContact().GetViewObjectContactRedirector()); - drawinglayer::primitive2d::Primitive2DSequence PagePrimitiveExtractor::createPrimitive2DSequenceForPage(const DisplayInfo& /*rDisplayInfo*/) - { - drawinglayer::primitive2d::Primitive2DSequence xRetval; - const SdrPage* pStartPage = GetStartPage(); - - if(pStartPage) - { - // update own ViewInformation2D for visualized page - const drawinglayer::geometry::ViewInformation2D& rOriginalViewInformation = mrViewObjectContactOfPageObj.GetObjectContact().getViewInformation2D(); - const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D( - rOriginalViewInformation.getObjectTransformation(), - rOriginalViewInformation.getViewTransformation(), - - // #i101075# use empty range for page content here to force - // the content not to be physically clipped in any way. This - // would be possible, but would require the internal transformation - // which maps between the page visualisation object and the page - // content, including the aspect ratios (for details see in - // PagePreviewPrimitive2D::create2DDecomposition) - basegfx::B2DRange(), - - GetXDrawPageForSdrPage(const_cast< SdrPage* >(pStartPage)), - 0.0, // no time; page previews are not animated - rOriginalViewInformation.getExtendedInformationSequence()); - updateViewInformation2D(aNewViewInformation2D); - - // create copy of DisplayInfo to set PagePainting - DisplayInfo aDisplayInfo; - - // get page's VOC - ViewObjectContact& rDrawPageVOContact = pStartPage->GetViewContact().GetViewObjectContact(*this); - - // get whole Primitive2DSequence - xRetval = rDrawPageVOContact.getPrimitive2DSequenceHierarchy(aDisplayInfo); - } - - return xRetval; + // create page content + xPageContent = mpExtractor->createPrimitive2DSequenceForPage(rDisplayInfo); + + // #i105548# reset VOCRedirector to not accidentially have a pointer to a + // temporary class, so calls to it are avoided safely + mpExtractor->SetViewObjectContactRedirector(0); + + // reset recursion flag + bInCreatePrimitive2D = false; } - void PagePrimitiveExtractor::InvalidatePartOfView(const basegfx::B2DRange& rRange) const + // prepare retval + if(xPageContent.hasElements()) { - // an invalidate is called at this view, this needs to be translated to an invalidate - // for the using VOC. Coordinates are in page coordinate system. - const SdrPage* pStartPage = GetStartPage(); - - if(pStartPage && !rRange.isEmpty()) - { - const basegfx::B2DRange aPageRange(0.0, 0.0, (double)pStartPage->GetWdt(), (double)pStartPage->GetHgt()); - - if(rRange.overlaps(aPageRange)) - { - // if object on the page is inside or overlapping with page, create ActionChanged() for - // involved VOC - mrViewObjectContactOfPageObj.ActionChanged(); - } - } + const uno::Reference< drawing::XDrawPage > xDrawPage(GetXDrawPageForSdrPage(const_cast< SdrPage*>(pPage))); + const drawinglayer::primitive2d::Primitive2DReference xPagePreview(new drawinglayer::primitive2d::PagePreviewPrimitive2D( + xDrawPage, aPageObjectTransform, fPageWidth, fPageHeight, xPageContent, true)); + xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xPagePreview, 1); } + } + else if(bCreateGrayFrame) + { + // #i105146# no content, but frame display. To make hitting the page preview objects + // on the handout page more simple, add hidden fill geometry + const drawinglayer::primitive2d::Primitive2DReference xFrameHit( + drawinglayer::primitive2d::createHiddenGeometryPrimitives2D( + false, + aPageObjectTransform)); + xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xFrameHit, 1); + } + + // add a gray outline frame, except not when printing + if(bCreateGrayFrame) + { + const Color aFrameColor(aColorConfig.GetColorValue(svtools::OBJECTBOUNDARIES).nColor); + basegfx::B2DPolygon aOwnOutline(basegfx::tools::createUnitPolygon()); + aOwnOutline.transform(aPageObjectTransform); - // forward access to SdrPageView to VOCOfPageObj - bool PagePrimitiveExtractor::isOutputToPrinter() const { return mrViewObjectContactOfPageObj.GetObjectContact().isOutputToPrinter(); } - bool PagePrimitiveExtractor::isOutputToWindow() const { return mrViewObjectContactOfPageObj.GetObjectContact().isOutputToWindow(); } - bool PagePrimitiveExtractor::isOutputToVirtualDevice() const { return mrViewObjectContactOfPageObj.GetObjectContact().isOutputToVirtualDevice(); } - bool PagePrimitiveExtractor::isOutputToRecordingMetaFile() const { return mrViewObjectContactOfPageObj.GetObjectContact().isOutputToRecordingMetaFile(); } - bool PagePrimitiveExtractor::isOutputToPDFFile() const { return mrViewObjectContactOfPageObj.GetObjectContact().isOutputToPDFFile(); } - bool PagePrimitiveExtractor::isDrawModeGray() const { return mrViewObjectContactOfPageObj.GetObjectContact().isDrawModeGray(); } - bool PagePrimitiveExtractor::isDrawModeBlackWhite() const { return mrViewObjectContactOfPageObj.GetObjectContact().isDrawModeBlackWhite(); } - bool PagePrimitiveExtractor::isDrawModeHighContrast() const { return mrViewObjectContactOfPageObj.GetObjectContact().isDrawModeHighContrast(); } - SdrPageView* PagePrimitiveExtractor::TryToGetSdrPageView() const { return mrViewObjectContactOfPageObj.GetObjectContact().TryToGetSdrPageView(); } - OutputDevice* PagePrimitiveExtractor::TryToGetOutputDevice() const { return mrViewObjectContactOfPageObj.GetObjectContact().TryToGetOutputDevice(); } - } // end of namespace contact -} // end of namespace sdr + const drawinglayer::primitive2d::Primitive2DReference xGrayFrame( + new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aOwnOutline, aFrameColor.getBColor())); + drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xGrayFrame); + } + return xRetval; +} -namespace sdr +ViewObjectContactOfPageObj::ViewObjectContactOfPageObj(ObjectContact& rObjectContact, ViewContact& rViewContact) +: ViewObjectContactOfSdrObj(rObjectContact, rViewContact), + mpExtractor(new PagePrimitiveExtractor(*this)) { - namespace contact - { - drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfPageObj::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const - { - drawinglayer::primitive2d::Primitive2DSequence xRetval; - const SdrPageObj& rPageObject((static_cast< ViewContactOfPageObj& >(GetViewContact())).GetPageObj()); - const SdrPage* pPage = rPageObject.GetReferencedPage(); - const svtools::ColorConfig aColorConfig; - - // get PageObject's geometry - basegfx::B2DHomMatrix aPageObjectTransform; - { - const Rectangle aPageObjectModelData(rPageObject.GetLastBoundRect()); - const basegfx::B2DRange aPageObjectBound( - aPageObjectModelData.Left(), aPageObjectModelData.Top(), - aPageObjectModelData.Right(), aPageObjectModelData.Bottom()); - - aPageObjectTransform.set(0, 0, aPageObjectBound.getWidth()); - aPageObjectTransform.set(1, 1, aPageObjectBound.getHeight()); - aPageObjectTransform.set(0, 2, aPageObjectBound.getMinX()); - aPageObjectTransform.set(1, 2, aPageObjectBound.getMinY()); - } - - // #i102637# add gray frame also when printing and page exists (handout pages) - const bool bCreateGrayFrame(!GetObjectContact().isOutputToPrinter() || pPage); - - // get displayed page's content. This is the uscaled page content - if(mpExtractor && pPage) - { - // get displayed page's geometry - drawinglayer::primitive2d::Primitive2DSequence xPageContent; - const Size aPageSize(pPage->GetSize()); - const double fPageWidth(aPageSize.getWidth()); - const double fPageHeight(aPageSize.getHeight()); - - // The case that a PageObject contains another PageObject which visualizes the - // same page again would lead to a recursion. Limit that recursion depth to one - // by using a local static bool - static bool bInCreatePrimitive2D(false); - - if(bInCreatePrimitive2D) - { - // Recursion is possible. Create a replacement primitive - xPageContent.realloc(2); - const Color aDocColor(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor); - const Color aBorderColor(aColorConfig.GetColorValue(svtools::DOCBOUNDARIES).nColor); - const basegfx::B2DRange aPageBound(0.0, 0.0, fPageWidth, fPageHeight); - const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aPageBound)); - - // add replacement fill - xPageContent[0L] = drawinglayer::primitive2d::Primitive2DReference( - new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aOutline), aDocColor.getBColor())); - - // add replacement border - xPageContent[1L] = drawinglayer::primitive2d::Primitive2DReference( - new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aOutline, aBorderColor.getBColor())); - } - else - { - // set recursion flag - bInCreatePrimitive2D = true; - - // init extractor, guarantee existence, set page there - mpExtractor->SetStartPage(pPage); - - // #i105548# also need to copy the VOCRedirector for sub-content creation - mpExtractor->SetViewObjectContactRedirector(GetObjectContact().GetViewObjectContactRedirector()); - - // create page content - xPageContent = mpExtractor->createPrimitive2DSequenceForPage(rDisplayInfo); - - // #i105548# reset VOCRedirector to not accidentially have a pointer to a - // temporary class, so calls to it are avoided safely - mpExtractor->SetViewObjectContactRedirector(0); - - // reset recursion flag - bInCreatePrimitive2D = false; - } - - // prepare retval - if(xPageContent.hasElements()) - { - const uno::Reference< drawing::XDrawPage > xDrawPage(GetXDrawPageForSdrPage(const_cast< SdrPage*>(pPage))); - const drawinglayer::primitive2d::Primitive2DReference xPagePreview(new drawinglayer::primitive2d::PagePreviewPrimitive2D( - xDrawPage, aPageObjectTransform, fPageWidth, fPageHeight, xPageContent, true)); - xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xPagePreview, 1); - } - } - else if(bCreateGrayFrame) - { - // #i105146# no content, but frame display. To make hitting the page preview objects - // on the handout page more simple, add hidden fill geometry - const drawinglayer::primitive2d::Primitive2DReference xFrameHit( - drawinglayer::primitive2d::createHiddenGeometryPrimitives2D( - false, - aPageObjectTransform)); - xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xFrameHit, 1); - } - - // add a gray outline frame, except not when printing - if(bCreateGrayFrame) - { - const Color aFrameColor(aColorConfig.GetColorValue(svtools::OBJECTBOUNDARIES).nColor); - basegfx::B2DPolygon aOwnOutline(basegfx::tools::createUnitPolygon()); - aOwnOutline.transform(aPageObjectTransform); - - const drawinglayer::primitive2d::Primitive2DReference xGrayFrame( - new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aOwnOutline, aFrameColor.getBColor())); - - drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xGrayFrame); - } - - return xRetval; - } - - ViewObjectContactOfPageObj::ViewObjectContactOfPageObj(ObjectContact& rObjectContact, ViewContact& rViewContact) - : ViewObjectContactOfSdrObj(rObjectContact, rViewContact), - mpExtractor(new PagePrimitiveExtractor(*this)) - { - } +} - ViewObjectContactOfPageObj::~ViewObjectContactOfPageObj() - { - // delete the helper OC - if(mpExtractor) - { - // remember candidate and reset own pointer to avoid action when createPrimitive2DSequence() - // would be called for any reason - PagePrimitiveExtractor* pCandidate = mpExtractor; - mpExtractor = 0; - - // also reset the StartPage to avoid ActionChanged() forwardings in the - // PagePrimitiveExtractor::InvalidatePartOfView() implementation - pCandidate->SetStartPage(0); - delete pCandidate; - } - } - } // end of namespace contact -} // end of namespace sdr +ViewObjectContactOfPageObj::~ViewObjectContactOfPageObj() +{ + // delete the helper OC + if(mpExtractor) + { + // remember candidate and reset own pointer to avoid action when createPrimitive2DSequence() + // would be called for any reason + PagePrimitiveExtractor* pCandidate = mpExtractor; + mpExtractor = 0; + + // also reset the StartPage to avoid ActionChanged() forwardings in the + // PagePrimitiveExtractor::InvalidatePartOfView() implementation + pCandidate->SetStartPage(0); + delete pCandidate; + } +} + +}} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/contact/viewobjectcontactredirector.cxx b/svx/source/sdr/contact/viewobjectcontactredirector.cxx index 375e0fb4da80..47110839f069 100644 --- a/svx/source/sdr/contact/viewobjectcontactredirector.cxx +++ b/svx/source/sdr/contact/viewobjectcontactredirector.cxx @@ -21,29 +21,25 @@ #include <svx/sdr/contact/viewobjectcontact.hxx> #include <svx/sdr/contact/viewcontact.hxx> +namespace sdr { namespace contact { +// basic constructor. +ViewObjectContactRedirector::ViewObjectContactRedirector() +{ +} -namespace sdr +// The destructor. +ViewObjectContactRedirector::~ViewObjectContactRedirector() { - namespace contact - { - // basic constructor. - ViewObjectContactRedirector::ViewObjectContactRedirector() - { - } +} - // The destructor. - ViewObjectContactRedirector::~ViewObjectContactRedirector() - { - } +drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactRedirector::createRedirectedPrimitive2DSequence( + const sdr::contact::ViewObjectContact& rOriginal, + const sdr::contact::DisplayInfo& rDisplayInfo) +{ + return rOriginal.createPrimitive2DSequence(rDisplayInfo); +} - drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactRedirector::createRedirectedPrimitive2DSequence( - const sdr::contact::ViewObjectContact& rOriginal, - const sdr::contact::DisplayInfo& rDisplayInfo) - { - return rOriginal.createPrimitive2DSequence(rDisplayInfo); - } - } // end of namespace contact -} // end of namespace sdr +}} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |