Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/controller/dialogs/TitleDialogData.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 <sal/config.h>
21
22
#include <TitleDialogData.hxx>
23
#include <TitleHelper.hxx>
24
#include <Diagram.hxx>
25
#include <AxisHelper.hxx>
26
#include <ChartModel.hxx>
27
28
namespace chart
29
{
30
using namespace ::com::sun::star;
31
32
TitleDialogData::TitleDialogData( std::optional<ReferenceSizeProvider> pRefSizeProvider )
33
0
        : aPossibilityList{ true, true, true, true, true, true, true }
34
0
        , aExistenceList{ false, false, false, false, false, false, false }
35
0
        , aTextList(7)
36
0
        , apReferenceSizeProvider( std::move(pRefSizeProvider) )
37
0
{
38
0
}
39
40
void TitleDialogData::readFromModel( const rtl::Reference<::chart::ChartModel>& xChartModel )
41
0
{
42
0
    rtl::Reference< Diagram > xDiagram = xChartModel->getFirstChartDiagram();
43
44
    //get possibilities
45
0
    uno::Sequence< sal_Bool > aAxisPossibilityList;
46
0
    AxisHelper::getAxisOrGridPossibilities( aAxisPossibilityList, xDiagram );
47
0
    sal_Bool* pPossibilityList = aPossibilityList.getArray();
48
0
    pPossibilityList[2]=aAxisPossibilityList[0];//x axis title
49
0
    pPossibilityList[3]=aAxisPossibilityList[1];//y axis title
50
0
    pPossibilityList[4]=aAxisPossibilityList[2];//z axis title
51
0
    pPossibilityList[5]=aAxisPossibilityList[3];//secondary x axis title
52
0
    pPossibilityList[6]=aAxisPossibilityList[4];//secondary y axis title
53
54
0
    sal_Bool* pExistenceList = aExistenceList.getArray();
55
0
    auto pTextList = aTextList.getArray();
56
    //find out which title exists and get their text
57
    //main title:
58
0
    for( auto nTitleIndex = +TitleHelper::TITLE_BEGIN;
59
0
         nTitleIndex < +TitleHelper::NORMAL_TITLE_END;
60
0
         nTitleIndex++)
61
0
    {
62
0
        rtl::Reference< Title > xTitle =  TitleHelper::getTitle(
63
0
            static_cast< TitleHelper::eTitleType >( nTitleIndex ), xChartModel );
64
0
        pExistenceList[nTitleIndex] = xTitle.is();
65
0
        pTextList[nTitleIndex]=TitleHelper::getCompleteString( xTitle );
66
0
    }
67
0
}
68
69
bool TitleDialogData::writeDifferenceToModel(
70
                          const rtl::Reference<::chart::ChartModel>& xChartModel
71
                        , const uno::Reference< uno::XComponentContext >& xContext
72
                        , const TitleDialogData* pOldState )
73
0
{
74
0
    bool bChanged = false;
75
0
    for( auto nN = +TitleHelper::TITLE_BEGIN;
76
0
         nN < +TitleHelper::NORMAL_TITLE_END;
77
0
         nN++)
78
0
    {
79
0
        if( !pOldState || ( pOldState->aExistenceList[nN] != aExistenceList[nN] ) )
80
0
        {
81
0
            if(aExistenceList[nN])
82
0
            {
83
0
                TitleHelper::createTitle(
84
0
                    static_cast< TitleHelper::eTitleType >( nN ), aTextList[nN], xChartModel, xContext,
85
0
                    apReferenceSizeProvider.has_value() ? &*apReferenceSizeProvider : nullptr );
86
0
                bChanged = true;
87
0
            }
88
0
            else
89
0
            {
90
0
                TitleHelper::removeTitle( static_cast< TitleHelper::eTitleType >( nN ), xChartModel );
91
0
                bChanged = true;
92
0
            }
93
0
        }
94
0
        else if( !pOldState || ( pOldState->aTextList[nN] != aTextList[nN] ) )
95
0
        {
96
            //change content
97
0
            rtl::Reference< Title > xTitle(
98
0
                TitleHelper::getTitle( static_cast< TitleHelper::eTitleType >( nN ), xChartModel ) );
99
0
            if(xTitle.is())
100
0
            {
101
0
                TitleHelper::setCompleteString( aTextList[nN], xTitle, xContext, nullptr, true );
102
0
                bChanged = true;
103
0
            }
104
0
        }
105
0
    }
106
0
    return bChanged;
107
0
}
108
109
} //namespace chart
110
111
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */