Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/tools/LinePropertiesHelper.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 <LinePropertiesHelper.hxx>
21
#include <com/sun/star/beans/PropertyAttribute.hpp>
22
#include <com/sun/star/beans/XPropertySet.hpp>
23
#include <com/sun/star/drawing/LineStyle.hpp>
24
#include <com/sun/star/drawing/LineDash.hpp>
25
#include <com/sun/star/drawing/LineCap.hpp>
26
#include <com/sun/star/drawing/LineJoint.hpp>
27
#include <com/sun/star/util/XComplexColor.hpp>
28
#include <comphelper/diagnose_ex.hxx>
29
#include <tools/color.hxx>
30
31
using namespace css;
32
33
namespace chart
34
{
35
36
void LinePropertiesHelper::AddPropertiesToVector(
37
    std::vector<beans::Property> & rOutProperties )
38
0
{
39
    // Line Properties see service drawing::LineProperties
40
0
    rOutProperties.emplace_back( "LineStyle",
41
0
                  PROP_LINE_STYLE,
42
0
                  cppu::UnoType<drawing::LineStyle>::get(),
43
0
                  beans::PropertyAttribute::BOUND
44
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
45
46
0
    rOutProperties.emplace_back( "LineDash",
47
0
                   PROP_LINE_DASH,
48
0
                   cppu::UnoType<drawing::LineDash>::get(),
49
0
                   beans::PropertyAttribute::BOUND
50
0
                   | beans::PropertyAttribute::MAYBEVOID );
51
52
//not in service description
53
0
    rOutProperties.emplace_back( "LineDashName",
54
0
                  PROP_LINE_DASH_NAME,
55
0
                  cppu::UnoType<OUString>::get(),
56
0
                  beans::PropertyAttribute::BOUND
57
0
                  | beans::PropertyAttribute::MAYBEDEFAULT
58
0
                  | beans::PropertyAttribute::MAYBEVOID );
59
60
0
    rOutProperties.emplace_back( "LineColor",
61
0
                  PROP_LINE_COLOR,
62
0
                  cppu::UnoType<sal_Int32>::get(),
63
0
                  beans::PropertyAttribute::BOUND
64
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
65
66
0
    rOutProperties.emplace_back("LineComplexColor",
67
0
                  PROP_LINE_COMPLEX_COLOR,
68
0
                  cppu::UnoType<util::XComplexColor>::get(),
69
0
                  beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT | beans::PropertyAttribute::MAYBEVOID);
70
71
0
    rOutProperties.emplace_back( "LineTransparence",
72
0
                  PROP_LINE_TRANSPARENCE,
73
0
                  cppu::UnoType<sal_Int16>::get(),
74
0
                  beans::PropertyAttribute::BOUND
75
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
76
77
0
    rOutProperties.emplace_back( "LineWidth",
78
0
                  PROP_LINE_WIDTH,
79
0
                  cppu::UnoType<sal_Int32>::get(),
80
0
                  beans::PropertyAttribute::BOUND
81
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
82
83
0
    rOutProperties.emplace_back( "LineJoint",
84
0
                  PROP_LINE_JOINT,
85
0
                  cppu::UnoType<drawing::LineJoint>::get(),
86
0
                  beans::PropertyAttribute::BOUND
87
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
88
89
0
    rOutProperties.emplace_back( "LineCap",
90
0
                  PROP_LINE_CAP,
91
0
                  cppu::UnoType<drawing::LineCap>::get(),
92
0
                  beans::PropertyAttribute::BOUND
93
0
                  | beans::PropertyAttribute::MAYBEDEFAULT );
94
0
}
95
96
void LinePropertiesHelper::AddDefaultsToMap(
97
    ::chart::tPropertyValueMap & rOutMap )
98
0
{
99
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_STYLE, drawing::LineStyle_SOLID );
100
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_WIDTH, sal_Int32(0) );
101
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_COLOR, COL_BLACK );
102
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_TRANSPARENCE, sal_Int16(0) );
103
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_JOINT, drawing::LineJoint_ROUND );
104
0
    ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_CAP, drawing::LineCap_BUTT );
105
0
}
106
107
bool LinePropertiesHelper::IsLineVisible( const css::uno::Reference<
108
        css::beans::XPropertySet >& xLineProperties )
109
0
{
110
0
    bool bRet = false;
111
0
    try
112
0
    {
113
0
        if( xLineProperties.is() )
114
0
        {
115
0
            drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
116
0
            xLineProperties->getPropertyValue( u"LineStyle"_ustr ) >>= aLineStyle;
117
0
            if( aLineStyle != drawing::LineStyle_NONE )
118
0
            {
119
0
                sal_Int16 nLineTransparence=0;
120
0
                xLineProperties->getPropertyValue( u"LineTransparence"_ustr ) >>= nLineTransparence;
121
0
                if(nLineTransparence!=100)
122
0
                {
123
0
                    bRet = true;
124
0
                }
125
0
            }
126
0
        }
127
0
    }
128
0
    catch( const uno::Exception & )
129
0
    {
130
0
        DBG_UNHANDLED_EXCEPTION("chart2");
131
0
    }
132
0
    return bRet;
133
0
}
134
135
void LinePropertiesHelper::SetLineVisible( const css::uno::Reference<
136
    css::beans::XPropertySet >& xLineProperties )
137
0
{
138
0
    try
139
0
    {
140
0
        if( xLineProperties.is() )
141
0
        {
142
0
            drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
143
0
            xLineProperties->getPropertyValue( u"LineStyle"_ustr ) >>= aLineStyle;
144
0
            if( aLineStyle == drawing::LineStyle_NONE )
145
0
                xLineProperties->setPropertyValue( u"LineStyle"_ustr, uno::Any( drawing::LineStyle_SOLID ) );
146
147
0
            sal_Int16 nLineTransparence=0;
148
0
            xLineProperties->getPropertyValue( u"LineTransparence"_ustr ) >>= nLineTransparence;
149
0
            if(nLineTransparence==100)
150
0
                xLineProperties->setPropertyValue( u"LineTransparence"_ustr, uno::Any( sal_Int16(0) ) );
151
0
        }
152
0
    }
153
0
    catch( const uno::Exception & )
154
0
    {
155
0
        DBG_UNHANDLED_EXCEPTION("chart2");
156
0
    }
157
0
}
158
159
void LinePropertiesHelper::SetLineInvisible( const css::uno::Reference<
160
    css::beans::XPropertySet >& xLineProperties )
161
0
{
162
0
    try
163
0
    {
164
0
        if( xLineProperties.is() )
165
0
        {
166
0
            drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
167
0
            xLineProperties->getPropertyValue( u"LineStyle"_ustr ) >>= aLineStyle;
168
0
            if( aLineStyle != drawing::LineStyle_NONE )
169
0
                xLineProperties->setPropertyValue( u"LineStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) );
170
0
        }
171
0
    }
172
0
    catch( const uno::Exception & )
173
0
    {
174
0
        DBG_UNHANDLED_EXCEPTION("chart2");
175
0
    }
176
0
}
177
178
void LinePropertiesHelper::SetLineColor( const css::uno::Reference<
179
     css::beans::XPropertySet >& xLineProperties, sal_Int32 nColor  )
180
0
{
181
0
    try
182
0
    {
183
0
        if( xLineProperties.is() )
184
0
        {
185
0
            xLineProperties->setPropertyValue( u"LineColor"_ustr, uno::Any( nColor ) );
186
0
        }
187
0
    }
188
0
    catch( const uno::Exception & )
189
0
    {
190
0
        DBG_UNHANDLED_EXCEPTION("chart2");
191
0
    }
192
0
}
193
194
195
} //  namespace chart
196
197
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */