merge the formfield patch from ooo-build
[ooovba.git] / chart2 / source / controller / dialogs / TitleDialogData.cxx
blobc1ab5a0fc872a100737d3cb0b91a8310846b357e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TitleDialogData.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "TitleDialogData.hxx"
35 #include "TitleHelper.hxx"
36 #include "ChartModelHelper.hxx"
37 #include "AxisHelper.hxx"
39 //.............................................................................
40 namespace chart
42 //.............................................................................
43 using namespace ::com::sun::star;
44 using namespace ::com::sun::star::chart2;
46 TitleDialogData::TitleDialogData( ::std::auto_ptr< ReferenceSizeProvider > apRefSizeProvider )
47 : aPossibilityList(7)
48 , aExistenceList(7)
49 , aTextList(7)
50 , apReferenceSizeProvider( apRefSizeProvider )
52 sal_Int32 nN = 0;
53 for(nN=7;nN--;)
54 aPossibilityList[nN]=sal_True;
55 for(nN=7;nN--;)
56 aExistenceList[nN]=sal_False;
59 void TitleDialogData::readFromModel( const uno::Reference< frame::XModel>& xChartModel )
61 uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram(xChartModel);
63 //get possibilities
64 uno::Sequence< sal_Bool > aAxisPossibilityList;
65 AxisHelper::getAxisOrGridPossibilities( aAxisPossibilityList, xDiagram );
66 this->aPossibilityList[2]=aAxisPossibilityList[0];//x axis title
67 this->aPossibilityList[3]=aAxisPossibilityList[1];//y axis title
68 this->aPossibilityList[4]=aAxisPossibilityList[2];//z axis title
69 this->aPossibilityList[5]=aAxisPossibilityList[3];//secondary x axis title
70 this->aPossibilityList[6]=aAxisPossibilityList[4];//secondary y axis title
72 //find out which title exsist and get their text
73 //main title:
74 for( sal_Int32 nTitleIndex = static_cast< sal_Int32 >( TitleHelper::TITLE_BEGIN);
75 nTitleIndex < static_cast< sal_Int32 >( TitleHelper::NORMAL_TITLE_END );
76 nTitleIndex++)
78 uno::Reference< XTitle > xTitle = TitleHelper::getTitle(
79 static_cast< TitleHelper::eTitleType >( nTitleIndex ), xChartModel );
80 this->aExistenceList[nTitleIndex] = xTitle.is();
81 this->aTextList[nTitleIndex]=TitleHelper::getCompleteString( xTitle );
85 bool TitleDialogData::writeDifferenceToModel(
86 const uno::Reference< frame::XModel >& xChartModel
87 , const uno::Reference< uno::XComponentContext >& xContext
88 , TitleDialogData* pOldState )
90 bool bChanged = false;
91 for( sal_Int32 nN = static_cast< sal_Int32 >( TitleHelper::TITLE_BEGIN );
92 nN < static_cast< sal_Int32 >( TitleHelper::NORMAL_TITLE_END );
93 nN++)
95 if( !pOldState || ( pOldState->aExistenceList[nN] != this->aExistenceList[nN] ) )
97 if(this->aExistenceList[nN])
99 TitleHelper::createTitle(
100 static_cast< TitleHelper::eTitleType >( nN ), this->aTextList[nN], xChartModel, xContext,
101 apReferenceSizeProvider.get() );
102 bChanged = true;
104 else
106 TitleHelper::removeTitle( static_cast< TitleHelper::eTitleType >( nN ), xChartModel );
107 bChanged = true;
110 else if( !pOldState || ( pOldState->aTextList[nN] != this->aTextList[nN] ) )
112 //change content
113 uno::Reference< XTitle > xTitle(
114 TitleHelper::getTitle( static_cast< TitleHelper::eTitleType >( nN ), xChartModel ) );
115 if(xTitle.is())
117 TitleHelper::setCompleteString( this->aTextList[nN], xTitle, xContext );
118 bChanged = true;
122 return bChanged;
125 //.............................................................................
126 } //namespace chart
127 //.............................................................................