1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sdext.hxx" 30 31 #include "optimizationstats.hxx" 32 #include <com/sun/star/awt/Size.hpp> 33 #include <com/sun/star/drawing/XShapes.hpp> 34 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> 35 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp> 36 37 38 using namespace ::rtl; 39 using namespace ::com::sun::star; 40 using namespace ::com::sun::star::uno; 41 using namespace ::com::sun::star::frame; 42 using namespace ::com::sun::star::drawing; 43 using namespace ::com::sun::star::beans; 44 45 // ----------------------------------------------------------------------------- 46 47 OptimizationStats::OptimizationStats() 48 { 49 } 50 51 // ----------------------------------------------------------------------------- 52 53 void OptimizationStats::SetStatusValue( const PPPOptimizerTokenEnum eStat, const uno::Any& rStatValue ) 54 { 55 maStats[ eStat ] = rStatValue; 56 } 57 58 // ----------------------------------------------------------------------------- 59 60 const uno::Any* OptimizationStats::GetStatusValue( const PPPOptimizerTokenEnum eStat ) const 61 { 62 std::map< PPPOptimizerTokenEnum, uno::Any, Compare >::const_iterator aIter( maStats.find( eStat ) ); 63 return aIter != maStats.end() ? &((*aIter).second) : NULL; 64 } 65 66 // ----------------------------------------------------------------------------- 67 68 com::sun::star::beans::PropertyValues OptimizationStats::GetStatusSequence() 69 { 70 int i = 0; 71 uno::Sequence< PropertyValue > aStatsSequence( maStats.size() ); 72 std::map< PPPOptimizerTokenEnum, uno::Any, Compare >::iterator aIter( maStats.begin() ); 73 while( aIter != maStats.end() ) 74 { 75 aStatsSequence[ i ].Name = TKGet( (*aIter).first ); 76 aStatsSequence[ i++ ].Value <<= (*aIter++).second; 77 } 78 return aStatsSequence; 79 } 80 81 // ----------------------------------------------------------------------------- 82 83 void OptimizationStats::InitializeStatusValues( const uno::Sequence< PropertyValue >& rOptimizationStats ) 84 { 85 for( int i = 0; i < rOptimizationStats.getLength(); i++ ) 86 rOptimizationStats[ i ].Value >>= maStats[ TKGet( rOptimizationStats[ i ].Name ) ]; 87 } 88 89 // ----------------------------------------------------------------------------- 90 91 void OptimizationStats::InitializeStatusValuesFromDocument( Reference< XModel > rxModel ) 92 { 93 try 94 { 95 Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW ); 96 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW ); 97 SetStatusValue( TK_Pages, Any( awt::Size( 0, xDrawPages->getCount() ) ) ); 98 } 99 catch ( Exception& ) 100 { 101 } 102 } 103