Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <svx/sdr/contact/viewcontactofunocontrol.hxx>
22 : #include <svx/sdr/contact/viewobjectcontactofunocontrol.hxx>
23 : #include <svx/sdr/contact/objectcontactofpageview.hxx>
24 : #include <svx/sdr/contact/displayinfo.hxx>
25 : #include <svx/svdouno.hxx>
26 : #include <svx/svdpagv.hxx>
27 : #include <svx/svdview.hxx>
28 : #include <svx/sdrpagewindow.hxx>
29 :
30 : #include <com/sun/star/awt/XWindow2.hpp>
31 :
32 : #include "svx/sdrpaintwindow.hxx"
33 : #include <tools/diagnose_ex.h>
34 : #include <vcl/pdfextoutdevdata.hxx>
35 : #include <basegfx/matrix/b2dhommatrix.hxx>
36 : #include <drawinglayer/primitive2d/controlprimitive2d.hxx>
37 : #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
38 :
39 : //........................................................................
40 : namespace sdr { namespace contact {
41 : //........................................................................
42 :
43 : using ::com::sun::star::awt::XControl;
44 : using ::com::sun::star::uno::Reference;
45 : using ::com::sun::star::awt::XControlContainer;
46 : using ::com::sun::star::awt::XControlModel;
47 : using ::com::sun::star::awt::XWindow2;
48 : using ::com::sun::star::uno::UNO_QUERY;
49 : using ::com::sun::star::uno::Exception;
50 :
51 : //====================================================================
52 : //= ViewContactOfUnoControl
53 : //====================================================================
54 : class ViewContactOfUnoControl_Impl
55 : {
56 : public:
57 : ViewContactOfUnoControl_Impl();
58 : ~ViewContactOfUnoControl_Impl();
59 :
60 : private:
61 : ViewContactOfUnoControl_Impl( const ViewContactOfUnoControl_Impl& ); // never implemented
62 : ViewContactOfUnoControl_Impl& operator=( const ViewContactOfUnoControl_Impl& ); // never implemented
63 : };
64 :
65 : //--------------------------------------------------------------------
66 300 : ViewContactOfUnoControl_Impl::ViewContactOfUnoControl_Impl()
67 : {
68 300 : }
69 :
70 : //--------------------------------------------------------------------
71 298 : ViewContactOfUnoControl_Impl::~ViewContactOfUnoControl_Impl()
72 : {
73 298 : }
74 :
75 : //====================================================================
76 : //= ViewContactOfUnoControl
77 : //====================================================================
78 : DBG_NAME( ViewContactOfUnoControl )
79 : //--------------------------------------------------------------------
80 300 : ViewContactOfUnoControl::ViewContactOfUnoControl( SdrUnoObj& _rUnoObject )
81 : :ViewContactOfSdrObj( _rUnoObject )
82 300 : ,m_pImpl( new ViewContactOfUnoControl_Impl )
83 : {
84 : DBG_CTOR( ViewContactOfUnoControl, NULL );
85 300 : }
86 :
87 : //--------------------------------------------------------------------
88 596 : ViewContactOfUnoControl::~ViewContactOfUnoControl()
89 : {
90 : DBG_DTOR( ViewContactOfUnoControl, NULL );
91 596 : }
92 :
93 : //--------------------------------------------------------------------
94 0 : Reference< XControl > ViewContactOfUnoControl::getTemporaryControlForWindow(
95 : const Window& _rWindow, Reference< XControlContainer >& _inout_ControlContainer ) const
96 : {
97 0 : SdrUnoObj* pUnoObject = dynamic_cast< SdrUnoObj* >( TryToGetSdrObject() );
98 : OSL_ENSURE( pUnoObject, "ViewContactOfUnoControl::getTemporaryControlForDevice: no SdrUnoObj!" );
99 0 : if ( !pUnoObject )
100 0 : return NULL;
101 0 : return ViewObjectContactOfUnoControl::getTemporaryControlForWindow( _rWindow, _inout_ControlContainer, *pUnoObject );
102 : }
103 :
104 : //--------------------------------------------------------------------
105 276 : ViewObjectContact& ViewContactOfUnoControl::CreateObjectSpecificViewObjectContact( ObjectContact& _rObjectContact )
106 : {
107 : // print or print preview requires special handling
108 276 : const OutputDevice* pDevice = _rObjectContact.TryToGetOutputDevice();
109 276 : bool bPrintOrPreview = ( pDevice != NULL ) && ( pDevice->GetOutDevType() == OUTDEV_PRINTER );
110 :
111 276 : ObjectContactOfPageView* pPageViewContact = dynamic_cast< ObjectContactOfPageView* >( &_rObjectContact );
112 276 : bPrintOrPreview |= ( pPageViewContact != NULL ) && pPageViewContact->GetPageWindow().GetPageView().GetView().IsPrintPreview();
113 :
114 276 : if ( bPrintOrPreview )
115 0 : return *new UnoControlPrintOrPreviewContact( *pPageViewContact, *this );
116 :
117 : // all others are nowadays served by the same implementation
118 276 : return *new ViewObjectContactOfUnoControl( _rObjectContact, *this );
119 : }
120 :
121 : //--------------------------------------------------------------------
122 554 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfUnoControl::createViewIndependentPrimitive2DSequence() const
123 : {
124 : // create range. Use model data directly, not getBoundRect()/getSnapRect; these will use
125 : // the primitive data themselves in the long run. Use SdrUnoObj's (which is a SdrRectObj)
126 : // call to GetGeoRect() to access SdrTextObj::aRect directly and without executing anything
127 554 : Rectangle aRectangle(GetSdrUnoObj().GetGeoRect());
128 : // Hack for calc, transform position of object according
129 : // to current zoom so as objects relative position to grid
130 : // appears stable
131 554 : Point aGridOffset = GetSdrUnoObj().GetGridOffset();
132 554 : aRectangle += aGridOffset;
133 : const basegfx::B2DRange aRange(
134 1108 : aRectangle.Left(), aRectangle.Top(),
135 1662 : aRectangle.Right(), aRectangle.Bottom());
136 :
137 : // create object transform
138 554 : basegfx::B2DHomMatrix aTransform;
139 :
140 554 : aTransform.set(0, 0, aRange.getWidth());
141 554 : aTransform.set(1, 1, aRange.getHeight());
142 554 : aTransform.set(0, 2, aRange.getMinX());
143 554 : aTransform.set(1, 2, aRange.getMinY());
144 :
145 1108 : Reference< XControlModel > xControlModel = GetSdrUnoObj().GetUnoControlModel();
146 :
147 554 : if(xControlModel.is())
148 : {
149 : // create control primitive WITHOUT possibly existing XControl; this would be done in
150 : // the VOC in createPrimitive2DSequence()
151 : const drawinglayer::primitive2d::Primitive2DReference xRetval(
152 : new drawinglayer::primitive2d::ControlPrimitive2D(
153 : aTransform,
154 527 : xControlModel));
155 :
156 527 : return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
157 : }
158 : else
159 : {
160 : // always append an invisible outline for the cases where no visible content exists
161 : const drawinglayer::primitive2d::Primitive2DReference xRetval(
162 : drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
163 27 : false, aTransform));
164 :
165 27 : return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
166 554 : }
167 : }
168 :
169 : //........................................................................
170 258 : } } // namespace sdr::contact
171 : //........................................................................
172 :
173 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|