LibreOffice Module chart2 (master) 1
TitleDialogData.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
22#include <TitleDialogData.hxx>
23#include <TitleHelper.hxx>
24#include <ChartModelHelper.hxx>
25#include <Diagram.hxx>
26#include <AxisHelper.hxx>
27#include <ChartModel.hxx>
28
29namespace chart
30{
31using namespace ::com::sun::star;
32using namespace ::com::sun::star::chart2;
33
34TitleDialogData::TitleDialogData( std::unique_ptr<ReferenceSizeProvider> pRefSizeProvider )
35 : aPossibilityList{ true, true, true, true, true, true, true }
36 , aExistenceList{ false, false, false, false, false, false, false }
37 , aTextList(7)
38 , apReferenceSizeProvider( std::move(pRefSizeProvider) )
39{
40}
41
43{
44 rtl::Reference< Diagram > xDiagram = xChartModel->getFirstChartDiagram();
45
46 //get possibilities
47 uno::Sequence< sal_Bool > aAxisPossibilityList;
48 AxisHelper::getAxisOrGridPossibilities( aAxisPossibilityList, xDiagram );
49 sal_Bool* pPossibilityList = aPossibilityList.getArray();
50 pPossibilityList[2]=aAxisPossibilityList[0];//x axis title
51 pPossibilityList[3]=aAxisPossibilityList[1];//y axis title
52 pPossibilityList[4]=aAxisPossibilityList[2];//z axis title
53 pPossibilityList[5]=aAxisPossibilityList[3];//secondary x axis title
54 pPossibilityList[6]=aAxisPossibilityList[4];//secondary y axis title
55
56 sal_Bool* pExistenceList = aExistenceList.getArray();
57 auto pTextList = aTextList.getArray();
58 //find out which title exists and get their text
59 //main title:
60 for( auto nTitleIndex = +TitleHelper::TITLE_BEGIN;
61 nTitleIndex < +TitleHelper::NORMAL_TITLE_END;
62 nTitleIndex++)
63 {
65 static_cast< TitleHelper::eTitleType >( nTitleIndex ), xChartModel );
66 pExistenceList[nTitleIndex] = xTitle.is();
67 pTextList[nTitleIndex]=TitleHelper::getCompleteString( xTitle );
68 }
69}
70
74 , const TitleDialogData* pOldState )
75{
76 bool bChanged = false;
77 for( auto nN = +TitleHelper::TITLE_BEGIN;
79 nN++)
80 {
81 if( !pOldState || ( pOldState->aExistenceList[nN] != aExistenceList[nN] ) )
82 {
83 if(aExistenceList[nN])
84 {
86 static_cast< TitleHelper::eTitleType >( nN ), aTextList[nN], xChartModel, xContext,
88 bChanged = true;
89 }
90 else
91 {
92 TitleHelper::removeTitle( static_cast< TitleHelper::eTitleType >( nN ), xChartModel );
93 bChanged = true;
94 }
95 }
96 else if( !pOldState || ( pOldState->aTextList[nN] != aTextList[nN] ) )
97 {
98 //change content
100 TitleHelper::getTitle( static_cast< TitleHelper::eTitleType >( nN ), xChartModel ) );
101 if(xTitle.is())
102 {
103 TitleHelper::setCompleteString( aTextList[nN], xTitle, xContext );
104 bChanged = true;
105 }
106 }
107 }
108 return bChanged;
109}
110
111} //namespace chart
112
113/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void getAxisOrGridPossibilities(css::uno::Sequence< sal_Bool > &rPossibilityList, const rtl::Reference< ::chart::Diagram > &xDiagram, bool bAxis=true)
Definition: AxisHelper.cxx:846
static void removeTitle(eTitleType nTitleIndex, const rtl::Reference< ::chart::ChartModel > &xModel)
static rtl::Reference< ::chart::Title > getTitle(eTitleType nTitleIndex, ChartModel &rModel)
static rtl::Reference< ::chart::Title > createTitle(eTitleType nTitleIndex, const OUString &rTitleText, const rtl::Reference< ::chart::ChartModel > &xModel, const css::uno::Reference< css::uno::XComponentContext > &xContext, ReferenceSizeProvider *pRefSizeProvider=nullptr)
static OUString getCompleteString(const rtl::Reference< ::chart::Title > &xTitle)
static void setCompleteString(const OUString &rNewText, const rtl::Reference< ::chart::Title > &xTitle, const css::uno::Reference< css::uno::XComponentContext > &xContext, const float *pDefaultCharHeight=nullptr)
std::unique_ptr< ReferenceSizeProvider > apReferenceSizeProvider
css::uno::Sequence< OUString > aTextList
bool writeDifferenceToModel(const rtl::Reference<::chart::ChartModel > &xChartModel, const css::uno::Reference< css::uno::XComponentContext > &xContext, const TitleDialogData *pOldState=nullptr)
css::uno::Sequence< sal_Bool > aPossibilityList
css::uno::Sequence< sal_Bool > aExistenceList
void readFromModel(const rtl::Reference<::chart::ChartModel > &xChartModel)
TitleDialogData(std::unique_ptr< ReferenceSizeProvider > pReferenzeSizeProvider=nullptr)
unsigned char sal_Bool