LibreOffice Module svx (master)  1
viewcontactofunocontrol.cxx
Go to the documentation of this file.
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 #include <sal/config.h>
21 
25 #include <svx/svdouno.hxx>
26 #include <svx/svdpagv.hxx>
27 #include <svx/svdview.hxx>
28 #include <svx/sdrpagewindow.hxx>
29 
30 #include <vcl/canvastools.hxx>
34 
35 
36 namespace sdr::contact {
37 
38 
39  using ::com::sun::star::awt::XControl;
40  using ::com::sun::star::uno::Reference;
41  using ::com::sun::star::awt::XControlContainer;
42  using ::com::sun::star::awt::XControlModel;
43 
44 
45  //= ViewContactOfUnoControl
46 
48  :ViewContactOfSdrObj( _rUnoObject )
49  {
50  }
51 
52 
54  {
55  }
56 
57 
59  const vcl::Window& _rWindow, Reference< XControlContainer >& _inout_ControlContainer ) const
60  {
61  SdrUnoObj* pUnoObject = dynamic_cast< SdrUnoObj* >( TryToGetSdrObject() );
62  OSL_ENSURE( pUnoObject, "ViewContactOfUnoControl::getTemporaryControlForDevice: no SdrUnoObj!" );
63  if ( !pUnoObject )
64  return nullptr;
65  return ViewObjectContactOfUnoControl::getTemporaryControlForWindow( _rWindow, _inout_ControlContainer, *pUnoObject );
66  }
67 
68 
70  {
71  // print or print preview requires special handling
72  const OutputDevice* pDevice = _rObjectContact.TryToGetOutputDevice();
73  ObjectContactOfPageView* const pPageViewContact = dynamic_cast< ObjectContactOfPageView* >( &_rObjectContact );
74 
75  const bool bPrintOrPreview = pPageViewContact
76  && ( ( ( pDevice != nullptr ) && ( pDevice->GetOutDevType() == OUTDEV_PRINTER ) )
77  || pPageViewContact->GetPageWindow().GetPageView().GetView().IsPrintPreview()
78  )
79  ;
80 
81  if ( bPrintOrPreview )
82  return *new UnoControlPrintOrPreviewContact( *pPageViewContact, *this );
83 
84  // all others are nowadays served by the same implementation
85  return *new ViewObjectContactOfUnoControl( _rObjectContact, *this );
86  }
87 
88 
90  {
91  // create range. Use model data directly, not getBoundRect()/getSnapRect; these will use
92  // the primitive data themselves in the long run. Use SdrUnoObj's (which is a SdrRectObj)
93  // call to GetGeoRect() to access SdrTextObj::aRect directly and without executing anything
95 
96  // create object transform
97  basegfx::B2DHomMatrix aTransform;
98 
99  aTransform.set(0, 0, aRange.getWidth());
100  aTransform.set(1, 1, aRange.getHeight());
101  aTransform.set(0, 2, aRange.getMinX());
102  aTransform.set(1, 2, aRange.getMinY());
103 
104  Reference< XControlModel > xControlModel = GetSdrUnoObj().GetUnoControlModel();
105 
106  if(xControlModel.is())
107  {
108  // create control primitive WITHOUT possibly existing XControl; this would be done in
109  // the VOC in createPrimitive2DSequence()
112  aTransform,
113  xControlModel));
114 
116  }
117  else
118  {
119  // always append an invisible outline for the cases where no visible content exists
122  aTransform));
123 
125  }
126  }
127 
128 
129 } // namespace sdr::contact
130 
131 
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OutDevType GetOutDevType() const
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
double getHeight() const
SdrView & GetView()
Definition: svdpagv.hxx:135
css::uno::Reference< css::awt::XControl > getTemporaryControlForWindow(const vcl::Window &_rWindow, css::uno::Reference< css::awt::XControlContainer > &_inout_ControlContainer) const
retrieves a temporary XControl instance, whose parent is the given window SdrUnoObj::GetTemporaryCon...
static css::uno::Reference< css::awt::XControl > getTemporaryControlForWindow(const vcl::Window &_rWindow, css::uno::Reference< css::awt::XControlContainer > &_inout_ControlContainer, const SdrUnoObj &_rUnoObject)
retrieves a temporary XControl instance, whose parent is the given device SdrUnoObj::GetTemporaryCon...
double getWidth() const
virtual drawinglayer::primitive2d::Primitive2DContainer createViewIndependentPrimitive2DSequence() const override
virtual SdrObject * TryToGetSdrObject() const override
override for accessing the SdrObject
OUTDEV_PRINTER
virtual ViewObjectContact & CreateObjectSpecificViewObjectContact(ObjectContact &_rObjectContact) override
basegfx::B2DRange b2DRectangleFromRectangle(const ::tools::Rectangle &rRect)
css::uno::Reference< css::graphic::XPrimitive2D > Primitive2DReference
double getMinY() const
Primitive2DReference createHiddenGeometryPrimitives2D(const basegfx::B2DHomMatrix &rMatrix)
bool IsPrintPreview() const
Definition: svdpntv.hxx:490
virtual OutputDevice * TryToGetOutputDevice() const
access to OutputDevice. May return 0L like the default implementations do. Override as needed...
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
Definition: svdouno.hxx:91
double getMinX() const
SdrPageView & GetPageView() const