1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 #include <svx/sdr/contact/viewcontactofunocontrol.hxx> 32 #include <svx/sdr/contact/viewobjectcontactofunocontrol.hxx> 33 #include <svx/sdr/contact/objectcontactofpageview.hxx> 34 #include <svx/sdr/contact/displayinfo.hxx> 35 #include <svx/svdouno.hxx> 36 #include <svx/svdpagv.hxx> 37 #include <svx/svdview.hxx> 38 #include <svx/sdrpagewindow.hxx> 39 40 /** === begin UNO includes === **/ 41 #include <com/sun/star/awt/XWindow2.hpp> 42 /** === end UNO includes === **/ 43 44 #include "svx/sdrpaintwindow.hxx" 45 #include <tools/diagnose_ex.h> 46 #include <vcl/pdfextoutdevdata.hxx> 47 #include <basegfx/matrix/b2dhommatrix.hxx> 48 #include <drawinglayer/primitive2d/controlprimitive2d.hxx> 49 #include <svx/sdr/contact/displayinfo.hxx> 50 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx> 51 52 //........................................................................ 53 namespace sdr { namespace contact { 54 //........................................................................ 55 56 /** === begin UNO using === **/ 57 using ::com::sun::star::awt::XControl; 58 using ::com::sun::star::uno::Reference; 59 using ::com::sun::star::awt::XControlContainer; 60 using ::com::sun::star::awt::XControlModel; 61 using ::com::sun::star::awt::XWindow2; 62 using ::com::sun::star::uno::UNO_QUERY; 63 using ::com::sun::star::uno::Exception; 64 /** === end UNO using === **/ 65 66 //==================================================================== 67 //= ViewContactOfUnoControl 68 //==================================================================== 69 class ViewContactOfUnoControl_Impl 70 { 71 public: 72 ViewContactOfUnoControl_Impl(); 73 ~ViewContactOfUnoControl_Impl(); 74 75 private: 76 ViewContactOfUnoControl_Impl( const ViewContactOfUnoControl_Impl& ); // never implemented 77 ViewContactOfUnoControl_Impl& operator=( const ViewContactOfUnoControl_Impl& ); // never implemented 78 }; 79 80 //-------------------------------------------------------------------- 81 ViewContactOfUnoControl_Impl::ViewContactOfUnoControl_Impl() 82 { 83 } 84 85 //-------------------------------------------------------------------- 86 ViewContactOfUnoControl_Impl::~ViewContactOfUnoControl_Impl() 87 { 88 } 89 90 //==================================================================== 91 //= ViewContactOfUnoControl 92 //==================================================================== 93 DBG_NAME( ViewContactOfUnoControl ) 94 //-------------------------------------------------------------------- 95 ViewContactOfUnoControl::ViewContactOfUnoControl( SdrUnoObj& _rUnoObject ) 96 :ViewContactOfSdrObj( _rUnoObject ) 97 ,m_pImpl( new ViewContactOfUnoControl_Impl ) 98 { 99 DBG_CTOR( ViewContactOfUnoControl, NULL ); 100 } 101 102 //-------------------------------------------------------------------- 103 ViewContactOfUnoControl::~ViewContactOfUnoControl() 104 { 105 DBG_DTOR( ViewContactOfUnoControl, NULL ); 106 } 107 108 //-------------------------------------------------------------------- 109 Reference< XControl > ViewContactOfUnoControl::getTemporaryControlForWindow( 110 const Window& _rWindow, Reference< XControlContainer >& _inout_ControlContainer ) const 111 { 112 SdrUnoObj* pUnoObject = dynamic_cast< SdrUnoObj* >( TryToGetSdrObject() ); 113 OSL_ENSURE( pUnoObject, "ViewContactOfUnoControl::getTemporaryControlForDevice: no SdrUnoObj!" ); 114 if ( !pUnoObject ) 115 return NULL; 116 return ViewObjectContactOfUnoControl::getTemporaryControlForWindow( _rWindow, _inout_ControlContainer, *pUnoObject ); 117 } 118 119 //-------------------------------------------------------------------- 120 ViewObjectContact& ViewContactOfUnoControl::CreateObjectSpecificViewObjectContact( ObjectContact& _rObjectContact ) 121 { 122 // print or print preview requires special handling 123 const OutputDevice* pDevice = _rObjectContact.TryToGetOutputDevice(); 124 bool bPrintOrPreview = ( pDevice != NULL ) && ( pDevice->GetOutDevType() == OUTDEV_PRINTER ); 125 126 ObjectContactOfPageView* pPageViewContact = dynamic_cast< ObjectContactOfPageView* >( &_rObjectContact ); 127 bPrintOrPreview |= ( pPageViewContact != NULL ) && pPageViewContact->GetPageWindow().GetPageView().GetView().IsPrintPreview(); 128 129 if ( bPrintOrPreview ) 130 return *new UnoControlPrintOrPreviewContact( *pPageViewContact, *this ); 131 132 // all others are nowadays served by the same implementation 133 return *new ViewObjectContactOfUnoControl( _rObjectContact, *this ); 134 } 135 136 //-------------------------------------------------------------------- 137 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfUnoControl::createViewIndependentPrimitive2DSequence() const 138 { 139 // create range. Use model data directly, not getBoundRect()/getSnapRect; these will use 140 // the primitive data themselves in the long run. Use SdrUnoObj's (which is a SdrRectObj) 141 // call to GetGeoRect() to access SdrTextObj::aRect directly and without executing anything 142 const Rectangle& rRectangle(GetSdrUnoObj().GetGeoRect()); 143 const basegfx::B2DRange aRange( 144 rRectangle.Left(), rRectangle.Top(), 145 rRectangle.Right(), rRectangle.Bottom()); 146 147 // create object transform 148 basegfx::B2DHomMatrix aTransform; 149 150 aTransform.set(0, 0, aRange.getWidth()); 151 aTransform.set(1, 1, aRange.getHeight()); 152 aTransform.set(0, 2, aRange.getMinX()); 153 aTransform.set(1, 2, aRange.getMinY()); 154 155 Reference< XControlModel > xControlModel = GetSdrUnoObj().GetUnoControlModel(); 156 157 if(xControlModel.is()) 158 { 159 // create control primitive WITHOUT possibly existing XControl; this would be done in 160 // the VOC in createPrimitive2DSequence() 161 const drawinglayer::primitive2d::Primitive2DReference xRetval( 162 new drawinglayer::primitive2d::ControlPrimitive2D( 163 aTransform, 164 xControlModel)); 165 166 return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1); 167 } 168 else 169 { 170 // always append an invisible outline for the cases where no visible content exists 171 const drawinglayer::primitive2d::Primitive2DReference xRetval( 172 drawinglayer::primitive2d::createHiddenGeometryPrimitives2D( 173 false, aTransform)); 174 175 return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1); 176 } 177 } 178 179 //........................................................................ 180 } } // namespace sdr::contact 181 //........................................................................ 182