1c142477cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3c142477cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4c142477cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5c142477cSAndrew Rist * distributed with this work for additional information 6c142477cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7c142477cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8c142477cSAndrew Rist * "License"); you may not use this file except in compliance 9c142477cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11c142477cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13c142477cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14c142477cSAndrew Rist * software distributed under the License is distributed on an 15c142477cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16c142477cSAndrew Rist * KIND, either express or implied. See the License for the 17c142477cSAndrew Rist * specific language governing permissions and limitations 18c142477cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20c142477cSAndrew Rist *************************************************************/ 21c142477cSAndrew Rist 22c142477cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sdext.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "optimizationstats.hxx" 28cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp> 29cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp> 30cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> 31cdf0e10cSrcweir #include <com/sun/star/drawing/XMasterPagesSupplier.hpp> 32cdf0e10cSrcweir 33cdf0e10cSrcweir 34cdf0e10cSrcweir using namespace ::com::sun::star; 35cdf0e10cSrcweir using namespace ::com::sun::star::uno; 36cdf0e10cSrcweir using namespace ::com::sun::star::frame; 37cdf0e10cSrcweir using namespace ::com::sun::star::drawing; 38cdf0e10cSrcweir using namespace ::com::sun::star::beans; 39cdf0e10cSrcweir 40*597a4c59SAriel Constenla-Haile using ::rtl::OUString; 41*597a4c59SAriel Constenla-Haile 42cdf0e10cSrcweir // ----------------------------------------------------------------------------- 43cdf0e10cSrcweir 44cdf0e10cSrcweir OptimizationStats::OptimizationStats() 45cdf0e10cSrcweir { 46cdf0e10cSrcweir } 47cdf0e10cSrcweir 48cdf0e10cSrcweir // ----------------------------------------------------------------------------- 49cdf0e10cSrcweir 50cdf0e10cSrcweir void OptimizationStats::SetStatusValue( const PPPOptimizerTokenEnum eStat, const uno::Any& rStatValue ) 51cdf0e10cSrcweir { 52cdf0e10cSrcweir maStats[ eStat ] = rStatValue; 53cdf0e10cSrcweir } 54cdf0e10cSrcweir 55cdf0e10cSrcweir // ----------------------------------------------------------------------------- 56cdf0e10cSrcweir 57cdf0e10cSrcweir const uno::Any* OptimizationStats::GetStatusValue( const PPPOptimizerTokenEnum eStat ) const 58cdf0e10cSrcweir { 59cdf0e10cSrcweir std::map< PPPOptimizerTokenEnum, uno::Any, Compare >::const_iterator aIter( maStats.find( eStat ) ); 60cdf0e10cSrcweir return aIter != maStats.end() ? &((*aIter).second) : NULL; 61cdf0e10cSrcweir } 62cdf0e10cSrcweir 63cdf0e10cSrcweir // ----------------------------------------------------------------------------- 64cdf0e10cSrcweir 65cdf0e10cSrcweir com::sun::star::beans::PropertyValues OptimizationStats::GetStatusSequence() 66cdf0e10cSrcweir { 67cdf0e10cSrcweir int i = 0; 68cdf0e10cSrcweir uno::Sequence< PropertyValue > aStatsSequence( maStats.size() ); 69cdf0e10cSrcweir std::map< PPPOptimizerTokenEnum, uno::Any, Compare >::iterator aIter( maStats.begin() ); 70cdf0e10cSrcweir while( aIter != maStats.end() ) 71cdf0e10cSrcweir { 72cdf0e10cSrcweir aStatsSequence[ i ].Name = TKGet( (*aIter).first ); 73cdf0e10cSrcweir aStatsSequence[ i++ ].Value <<= (*aIter++).second; 74cdf0e10cSrcweir } 75cdf0e10cSrcweir return aStatsSequence; 76cdf0e10cSrcweir } 77cdf0e10cSrcweir 78cdf0e10cSrcweir // ----------------------------------------------------------------------------- 79cdf0e10cSrcweir 80cdf0e10cSrcweir void OptimizationStats::InitializeStatusValues( const uno::Sequence< PropertyValue >& rOptimizationStats ) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir for( int i = 0; i < rOptimizationStats.getLength(); i++ ) 83cdf0e10cSrcweir rOptimizationStats[ i ].Value >>= maStats[ TKGet( rOptimizationStats[ i ].Name ) ]; 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir // ----------------------------------------------------------------------------- 87cdf0e10cSrcweir 88cdf0e10cSrcweir void OptimizationStats::InitializeStatusValuesFromDocument( Reference< XModel > rxModel ) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir try 91cdf0e10cSrcweir { 92cdf0e10cSrcweir Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW ); 93cdf0e10cSrcweir Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW ); 94cdf0e10cSrcweir SetStatusValue( TK_Pages, Any( awt::Size( 0, xDrawPages->getCount() ) ) ); 95cdf0e10cSrcweir } 96cdf0e10cSrcweir catch ( Exception& ) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir } 99cdf0e10cSrcweir } 100