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