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 : #include <svx/sdr/contact/viewcontactofvirtobj.hxx>
21 : #include <svx/svdovirt.hxx>
22 : #include <svx/sdr/contact/displayinfo.hxx>
23 : #include <basegfx/matrix/b2dhommatrix.hxx>
24 : #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
25 : #include <vcl/outdev.hxx>
26 : #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
27 :
28 : namespace sdr { namespace contact {
29 :
30 2327 : ViewContactOfVirtObj::ViewContactOfVirtObj(SdrVirtObj& rObj)
31 2327 : : ViewContactOfSdrObj(rObj)
32 : {
33 2327 : }
34 :
35 2327 : ViewContactOfVirtObj::~ViewContactOfVirtObj()
36 : {
37 2327 : }
38 :
39 658 : SdrVirtObj& ViewContactOfVirtObj::GetVirtObj() const
40 : {
41 658 : return static_cast<SdrVirtObj&>(mrObject);
42 : }
43 :
44 : // Access to possible sub-hierarchy
45 2536 : sal_uInt32 ViewContactOfVirtObj::GetObjectCount() const
46 : {
47 : // Here, SdrVirtObj's need to return 0L to show that they have no
48 : // sub-hierarchy, even when they are group objects. This is necessary
49 : // to avoid that the same VOCs will be added to the draw hierarchy
50 : // twice which leads to problems.
51 :
52 : // This solution is only a first solution to get things running. Later
53 : // this needs to be replaced with creating real VOCs for the objects
54 : // referenced by virtual objects to avoid the 'trick' of setting the
55 : // offset for painting at the destination OutputDevive.
56 :
57 : // As can be seen, with primitives, the problem will be solved using
58 : // a transformPrimitive, so this solution can stay with primitives.
59 2536 : return 0L;
60 : }
61 :
62 329 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfVirtObj::createViewIndependentPrimitive2DSequence() const
63 : {
64 : // create displacement transformation if we have content
65 329 : basegfx::B2DHomMatrix aObjectMatrix;
66 329 : Point aAnchor(GetVirtObj().GetAnchorPos());
67 :
68 329 : if(aAnchor.X() || aAnchor.Y())
69 : {
70 323 : aObjectMatrix.set(0, 2, aAnchor.X());
71 323 : aObjectMatrix.set(1, 2, aAnchor.Y());
72 : }
73 :
74 : // use method from referenced object to get the Primitive2DSequence
75 : const drawinglayer::primitive2d::Primitive2DSequence xSequenceVirtual(
76 658 : GetVirtObj().GetReferencedObj().GetViewContact().getViewIndependentPrimitive2DSequence());
77 :
78 329 : if(xSequenceVirtual.hasElements())
79 : {
80 : // create transform primitive
81 : const drawinglayer::primitive2d::Primitive2DReference xReference(
82 : new drawinglayer::primitive2d::TransformPrimitive2D(
83 : aObjectMatrix,
84 329 : xSequenceVirtual));
85 :
86 329 : return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
87 : }
88 : else
89 : {
90 : // always append an invisible outline for the cases where no visible content exists
91 : const drawinglayer::primitive2d::Primitive2DReference xReference(
92 : drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
93 0 : false, aObjectMatrix));
94 :
95 0 : return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
96 329 : }
97 : }
98 :
99 : }}
100 :
101 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
102 :
|