Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / chart2 / source / controller / dialogs / TitleDialogData.cxx
blob907bc7324fdaefe1367758b56a3e6072116b7c0c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <TitleDialogData.hxx>
21 #include <TitleHelper.hxx>
22 #include <ChartModelHelper.hxx>
23 #include <AxisHelper.hxx>
25 namespace chart
27 using namespace ::com::sun::star;
28 using namespace ::com::sun::star::chart2;
30 TitleDialogData::TitleDialogData( std::unique_ptr<ReferenceSizeProvider> pRefSizeProvider )
31 : aPossibilityList(7)
32 , aExistenceList(7)
33 , aTextList(7)
34 , apReferenceSizeProvider( std::move(pRefSizeProvider) )
36 for (sal_Int32 i = 0; i < 7; i++)
38 aPossibilityList[i] = true;
39 aExistenceList[i] = false;
43 void TitleDialogData::readFromModel( const uno::Reference< frame::XModel>& xChartModel )
45 uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram(xChartModel);
47 //get possibilities
48 uno::Sequence< sal_Bool > aAxisPossibilityList;
49 AxisHelper::getAxisOrGridPossibilities( aAxisPossibilityList, xDiagram );
50 aPossibilityList[2]=aAxisPossibilityList[0];//x axis title
51 aPossibilityList[3]=aAxisPossibilityList[1];//y axis title
52 aPossibilityList[4]=aAxisPossibilityList[2];//z axis title
53 aPossibilityList[5]=aAxisPossibilityList[3];//secondary x axis title
54 aPossibilityList[6]=aAxisPossibilityList[4];//secondary y axis title
56 //find out which title exists and get their text
57 //main title:
58 for( sal_Int32 nTitleIndex = static_cast< sal_Int32 >( TitleHelper::TITLE_BEGIN);
59 nTitleIndex < static_cast< sal_Int32 >( TitleHelper::NORMAL_TITLE_END );
60 nTitleIndex++)
62 uno::Reference< XTitle > xTitle = TitleHelper::getTitle(
63 static_cast< TitleHelper::eTitleType >( nTitleIndex ), xChartModel );
64 aExistenceList[nTitleIndex] = xTitle.is();
65 aTextList[nTitleIndex]=TitleHelper::getCompleteString( xTitle );
69 bool TitleDialogData::writeDifferenceToModel(
70 const uno::Reference< frame::XModel >& xChartModel
71 , const uno::Reference< uno::XComponentContext >& xContext
72 , TitleDialogData* pOldState )
74 bool bChanged = false;
75 for( sal_Int32 nN = static_cast< sal_Int32 >( TitleHelper::TITLE_BEGIN );
76 nN < static_cast< sal_Int32 >( TitleHelper::NORMAL_TITLE_END );
77 nN++)
79 if( !pOldState || ( pOldState->aExistenceList[nN] != aExistenceList[nN] ) )
81 if(aExistenceList[nN])
83 TitleHelper::createTitle(
84 static_cast< TitleHelper::eTitleType >( nN ), aTextList[nN], xChartModel, xContext,
85 apReferenceSizeProvider.get() );
86 bChanged = true;
88 else
90 TitleHelper::removeTitle( static_cast< TitleHelper::eTitleType >( nN ), xChartModel );
91 bChanged = true;
94 else if( !pOldState || ( pOldState->aTextList[nN] != aTextList[nN] ) )
96 //change content
97 uno::Reference< XTitle > xTitle(
98 TitleHelper::getTitle( static_cast< TitleHelper::eTitleType >( nN ), xChartModel ) );
99 if(xTitle.is())
101 TitleHelper::setCompleteString( aTextList[nN], xTitle, xContext );
102 bChanged = true;
106 return bChanged;
109 } //namespace chart
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */