update dev300-m58
[ooovba.git] / sdext / source / minimizer / optimizationstats.cxx
blob512c9ace9414cd1c088849e6be587d54a347e159
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: optimizationstats.cxx,v $
11 * $Revision: 1.3 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_sdext.hxx"
35 #include "optimizationstats.hxx"
36 #include <com/sun/star/awt/Size.hpp>
37 #include <com/sun/star/drawing/XShapes.hpp>
38 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
39 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
42 using namespace ::rtl;
43 using namespace ::com::sun::star;
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::frame;
46 using namespace ::com::sun::star::drawing;
47 using namespace ::com::sun::star::beans;
49 // -----------------------------------------------------------------------------
51 OptimizationStats::OptimizationStats()
55 // -----------------------------------------------------------------------------
57 void OptimizationStats::SetStatusValue( const PPPOptimizerTokenEnum eStat, const uno::Any& rStatValue )
59 maStats[ eStat ] = rStatValue;
62 // -----------------------------------------------------------------------------
64 const uno::Any* OptimizationStats::GetStatusValue( const PPPOptimizerTokenEnum eStat ) const
66 std::map< PPPOptimizerTokenEnum, uno::Any, Compare >::const_iterator aIter( maStats.find( eStat ) );
67 return aIter != maStats.end() ? &((*aIter).second) : NULL;
70 // -----------------------------------------------------------------------------
72 com::sun::star::beans::PropertyValues OptimizationStats::GetStatusSequence()
74 int i = 0;
75 uno::Sequence< PropertyValue > aStatsSequence( maStats.size() );
76 std::map< PPPOptimizerTokenEnum, uno::Any, Compare >::iterator aIter( maStats.begin() );
77 while( aIter != maStats.end() )
79 aStatsSequence[ i ].Name = TKGet( (*aIter).first );
80 aStatsSequence[ i++ ].Value <<= (*aIter++).second;
82 return aStatsSequence;
85 // -----------------------------------------------------------------------------
87 void OptimizationStats::InitializeStatusValues( const uno::Sequence< PropertyValue >& rOptimizationStats )
89 for( int i = 0; i < rOptimizationStats.getLength(); i++ )
90 rOptimizationStats[ i ].Value >>= maStats[ TKGet( rOptimizationStats[ i ].Name ) ];
93 // -----------------------------------------------------------------------------
95 void OptimizationStats::InitializeStatusValuesFromDocument( Reference< XModel > rxModel )
97 try
99 Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW );
100 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
101 SetStatusValue( TK_Pages, Any( awt::Size( 0, xDrawPages->getCount() ) ) );
103 catch ( Exception& )