1*f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f6e50924SAndrew Rist * distributed with this work for additional information 6*f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9*f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10*f6e50924SAndrew Rist * 11*f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*f6e50924SAndrew Rist * 13*f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f6e50924SAndrew Rist * software distributed under the License is distributed on an 15*f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17*f6e50924SAndrew Rist * specific language governing permissions and limitations 18*f6e50924SAndrew Rist * under the License. 19*f6e50924SAndrew Rist * 20*f6e50924SAndrew Rist *************************************************************/ 21*f6e50924SAndrew Rist 22*f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofunocontrol.hxx> 28cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontactofunocontrol.hxx> 29cdf0e10cSrcweir #include <svx/sdr/contact/objectcontactofpageview.hxx> 30cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx> 31cdf0e10cSrcweir #include <svx/svdouno.hxx> 32cdf0e10cSrcweir #include <svx/svdpagv.hxx> 33cdf0e10cSrcweir #include <svx/svdview.hxx> 34cdf0e10cSrcweir #include <svx/sdrpagewindow.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir /** === begin UNO includes === **/ 37cdf0e10cSrcweir #include <com/sun/star/awt/XWindow2.hpp> 38cdf0e10cSrcweir /** === end UNO includes === **/ 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include "svx/sdrpaintwindow.hxx" 41cdf0e10cSrcweir #include <tools/diagnose_ex.h> 42cdf0e10cSrcweir #include <vcl/pdfextoutdevdata.hxx> 43cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 44cdf0e10cSrcweir #include <drawinglayer/primitive2d/controlprimitive2d.hxx> 45cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx> 46cdf0e10cSrcweir #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx> 47cdf0e10cSrcweir 48cdf0e10cSrcweir //........................................................................ 49cdf0e10cSrcweir namespace sdr { namespace contact { 50cdf0e10cSrcweir //........................................................................ 51cdf0e10cSrcweir 52cdf0e10cSrcweir /** === begin UNO using === **/ 53cdf0e10cSrcweir using ::com::sun::star::awt::XControl; 54cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 55cdf0e10cSrcweir using ::com::sun::star::awt::XControlContainer; 56cdf0e10cSrcweir using ::com::sun::star::awt::XControlModel; 57cdf0e10cSrcweir using ::com::sun::star::awt::XWindow2; 58cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 59cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 60cdf0e10cSrcweir /** === end UNO using === **/ 61cdf0e10cSrcweir 62cdf0e10cSrcweir //==================================================================== 63cdf0e10cSrcweir //= ViewContactOfUnoControl 64cdf0e10cSrcweir //==================================================================== 65cdf0e10cSrcweir class ViewContactOfUnoControl_Impl 66cdf0e10cSrcweir { 67cdf0e10cSrcweir public: 68cdf0e10cSrcweir ViewContactOfUnoControl_Impl(); 69cdf0e10cSrcweir ~ViewContactOfUnoControl_Impl(); 70cdf0e10cSrcweir 71cdf0e10cSrcweir private: 72cdf0e10cSrcweir ViewContactOfUnoControl_Impl( const ViewContactOfUnoControl_Impl& ); // never implemented 73cdf0e10cSrcweir ViewContactOfUnoControl_Impl& operator=( const ViewContactOfUnoControl_Impl& ); // never implemented 74cdf0e10cSrcweir }; 75cdf0e10cSrcweir 76cdf0e10cSrcweir //-------------------------------------------------------------------- ViewContactOfUnoControl_Impl()77cdf0e10cSrcweir ViewContactOfUnoControl_Impl::ViewContactOfUnoControl_Impl() 78cdf0e10cSrcweir { 79cdf0e10cSrcweir } 80cdf0e10cSrcweir 81cdf0e10cSrcweir //-------------------------------------------------------------------- ~ViewContactOfUnoControl_Impl()82cdf0e10cSrcweir ViewContactOfUnoControl_Impl::~ViewContactOfUnoControl_Impl() 83cdf0e10cSrcweir { 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir //==================================================================== 87cdf0e10cSrcweir //= ViewContactOfUnoControl 88cdf0e10cSrcweir //==================================================================== DBG_NAME(ViewContactOfUnoControl)89cdf0e10cSrcweir DBG_NAME( ViewContactOfUnoControl ) 90cdf0e10cSrcweir //-------------------------------------------------------------------- 91cdf0e10cSrcweir ViewContactOfUnoControl::ViewContactOfUnoControl( SdrUnoObj& _rUnoObject ) 92cdf0e10cSrcweir :ViewContactOfSdrObj( _rUnoObject ) 93cdf0e10cSrcweir ,m_pImpl( new ViewContactOfUnoControl_Impl ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir DBG_CTOR( ViewContactOfUnoControl, NULL ); 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir //-------------------------------------------------------------------- ~ViewContactOfUnoControl()99cdf0e10cSrcweir ViewContactOfUnoControl::~ViewContactOfUnoControl() 100cdf0e10cSrcweir { 101cdf0e10cSrcweir DBG_DTOR( ViewContactOfUnoControl, NULL ); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir 104cdf0e10cSrcweir //-------------------------------------------------------------------- getTemporaryControlForWindow(const Window & _rWindow,Reference<XControlContainer> & _inout_ControlContainer) const105cdf0e10cSrcweir Reference< XControl > ViewContactOfUnoControl::getTemporaryControlForWindow( 106cdf0e10cSrcweir const Window& _rWindow, Reference< XControlContainer >& _inout_ControlContainer ) const 107cdf0e10cSrcweir { 108cdf0e10cSrcweir SdrUnoObj* pUnoObject = dynamic_cast< SdrUnoObj* >( TryToGetSdrObject() ); 109cdf0e10cSrcweir OSL_ENSURE( pUnoObject, "ViewContactOfUnoControl::getTemporaryControlForDevice: no SdrUnoObj!" ); 110cdf0e10cSrcweir if ( !pUnoObject ) 111cdf0e10cSrcweir return NULL; 112cdf0e10cSrcweir return ViewObjectContactOfUnoControl::getTemporaryControlForWindow( _rWindow, _inout_ControlContainer, *pUnoObject ); 113cdf0e10cSrcweir } 114cdf0e10cSrcweir 115cdf0e10cSrcweir //-------------------------------------------------------------------- CreateObjectSpecificViewObjectContact(ObjectContact & _rObjectContact)116cdf0e10cSrcweir ViewObjectContact& ViewContactOfUnoControl::CreateObjectSpecificViewObjectContact( ObjectContact& _rObjectContact ) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir // print or print preview requires special handling 119cdf0e10cSrcweir const OutputDevice* pDevice = _rObjectContact.TryToGetOutputDevice(); 120cdf0e10cSrcweir bool bPrintOrPreview = ( pDevice != NULL ) && ( pDevice->GetOutDevType() == OUTDEV_PRINTER ); 121cdf0e10cSrcweir 122cdf0e10cSrcweir ObjectContactOfPageView* pPageViewContact = dynamic_cast< ObjectContactOfPageView* >( &_rObjectContact ); 123cdf0e10cSrcweir bPrintOrPreview |= ( pPageViewContact != NULL ) && pPageViewContact->GetPageWindow().GetPageView().GetView().IsPrintPreview(); 124cdf0e10cSrcweir 125cdf0e10cSrcweir if ( bPrintOrPreview ) 126cdf0e10cSrcweir return *new UnoControlPrintOrPreviewContact( *pPageViewContact, *this ); 127cdf0e10cSrcweir 128cdf0e10cSrcweir // all others are nowadays served by the same implementation 129cdf0e10cSrcweir return *new ViewObjectContactOfUnoControl( _rObjectContact, *this ); 130cdf0e10cSrcweir } 131cdf0e10cSrcweir 132cdf0e10cSrcweir //-------------------------------------------------------------------- createViewIndependentPrimitive2DSequence() const133cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence ViewContactOfUnoControl::createViewIndependentPrimitive2DSequence() const 134cdf0e10cSrcweir { 135cdf0e10cSrcweir // create range. Use model data directly, not getBoundRect()/getSnapRect; these will use 136cdf0e10cSrcweir // the primitive data themselves in the long run. Use SdrUnoObj's (which is a SdrRectObj) 137cdf0e10cSrcweir // call to GetGeoRect() to access SdrTextObj::aRect directly and without executing anything 138cdf0e10cSrcweir const Rectangle& rRectangle(GetSdrUnoObj().GetGeoRect()); 139cdf0e10cSrcweir const basegfx::B2DRange aRange( 140cdf0e10cSrcweir rRectangle.Left(), rRectangle.Top(), 141cdf0e10cSrcweir rRectangle.Right(), rRectangle.Bottom()); 142cdf0e10cSrcweir 143cdf0e10cSrcweir // create object transform 144cdf0e10cSrcweir basegfx::B2DHomMatrix aTransform; 145cdf0e10cSrcweir 146cdf0e10cSrcweir aTransform.set(0, 0, aRange.getWidth()); 147cdf0e10cSrcweir aTransform.set(1, 1, aRange.getHeight()); 148cdf0e10cSrcweir aTransform.set(0, 2, aRange.getMinX()); 149cdf0e10cSrcweir aTransform.set(1, 2, aRange.getMinY()); 150cdf0e10cSrcweir 151cdf0e10cSrcweir Reference< XControlModel > xControlModel = GetSdrUnoObj().GetUnoControlModel(); 152cdf0e10cSrcweir 153cdf0e10cSrcweir if(xControlModel.is()) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir // create control primitive WITHOUT possibly existing XControl; this would be done in 156cdf0e10cSrcweir // the VOC in createPrimitive2DSequence() 157cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DReference xRetval( 158cdf0e10cSrcweir new drawinglayer::primitive2d::ControlPrimitive2D( 159cdf0e10cSrcweir aTransform, 160cdf0e10cSrcweir xControlModel)); 161cdf0e10cSrcweir 162cdf0e10cSrcweir return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1); 163cdf0e10cSrcweir } 164cdf0e10cSrcweir else 165cdf0e10cSrcweir { 166cdf0e10cSrcweir // always append an invisible outline for the cases where no visible content exists 167cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DReference xRetval( 168cdf0e10cSrcweir drawinglayer::primitive2d::createHiddenGeometryPrimitives2D( 169cdf0e10cSrcweir false, aTransform)); 170cdf0e10cSrcweir 171cdf0e10cSrcweir return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1); 172cdf0e10cSrcweir } 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir //........................................................................ 176cdf0e10cSrcweir } } // namespace sdr::contact 177cdf0e10cSrcweir //........................................................................ 178