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