Coverage Report

Created: 2026-09-28 10:59

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