LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/filter/source/graphic - GraphicExportDialog.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 57 0.0 %
Date: 2013-07-09 Functions: 0 11 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "GraphicExportDialog.hxx"
      21             : 
      22             : #include <vcl/graphicfilter.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : 
      25             : #include <com/sun/star/frame/XModel.hpp>
      26             : #include <com/sun/star/container/XIndexAccess.hpp>
      27             : #include <com/sun/star/lang/XServiceInfo.hpp>
      28             : #include <com/sun/star/uno/Sequence.h>
      29             : #include <com/sun/star/uno/Any.h>
      30             : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
      31             : 
      32             : #include <svtools/GraphicExportOptionsDialog.hxx>
      33             : 
      34             : using namespace css;
      35             : using namespace css::uno;
      36             : using namespace css::beans;
      37             : using namespace css::lang;
      38             : 
      39           0 : GraphicExportDialog::GraphicExportDialog( const Reference< XComponentContext >& rxContext ) :
      40             :     mxContext           ( rxContext ),
      41           0 :     mbExportSelection   ( sal_False )
      42             : {
      43           0 : }
      44             : 
      45           0 : GraphicExportDialog::~GraphicExportDialog()
      46             : {
      47           0 : }
      48             : 
      49             : // XInitialization
      50           0 : void SAL_CALL GraphicExportDialog::initialize( const Sequence<Any>& ) throw ( Exception, RuntimeException )
      51           0 : {}
      52             : 
      53             : // XPropertyAccess
      54           0 : Sequence<PropertyValue> GraphicExportDialog::getPropertyValues() throw ( RuntimeException )
      55             : {
      56             :     sal_Int32 i;
      57           0 :     sal_Int32 nCount = maMediaDescriptor.getLength();
      58             : 
      59           0 :     for ( i = 0; i < nCount; i++ )
      60             :     {
      61           0 :         if ( maMediaDescriptor[ i ].Name == "FilterData" )
      62             :         {
      63           0 :             break;
      64             :         }
      65             :     }
      66             : 
      67           0 :     if ( i >= nCount )
      68             :     {
      69           0 :         nCount++;
      70           0 :         maMediaDescriptor.realloc( nCount );
      71             :     }
      72             : 
      73           0 :     maMediaDescriptor[ i ].Name = OUString( "FilterData" );
      74           0 :     maMediaDescriptor[ i ].Value <<= maFilterDataSequence;
      75           0 :     return maMediaDescriptor;
      76             : }
      77             : 
      78           0 : void GraphicExportDialog::setPropertyValues( const Sequence<PropertyValue>& aProps )
      79             :     throw ( UnknownPropertyException, PropertyVetoException, IllegalArgumentException,
      80             :             WrappedTargetException, RuntimeException )
      81             : {
      82           0 :     maMediaDescriptor = aProps;
      83             : 
      84             :     sal_Int32 i, nCount;
      85           0 :     for ( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
      86             :     {
      87           0 :         if ( maMediaDescriptor[ i ].Name == "FilterData" )
      88             :         {
      89           0 :             maMediaDescriptor[ i ].Value >>= maFilterDataSequence;
      90             :         }
      91           0 :         else if ( maMediaDescriptor[ i ].Name == "SelectionOnly" )
      92             :         {
      93           0 :             maMediaDescriptor[ i ].Value >>= mbExportSelection;
      94             :         }
      95             :     }
      96           0 : }
      97             : 
      98             : // XExecutableDialog
      99           0 : void GraphicExportDialog::setTitle( const OUString& aTitle )
     100             :     throw ( uno::RuntimeException )
     101             : {
     102           0 :     maDialogTitle = aTitle;
     103           0 : }
     104             : 
     105           0 : sal_Int16 GraphicExportDialog::execute() throw ( RuntimeException )
     106             : {
     107           0 :     sal_Int16 nReturn = ui::dialogs::ExecutableDialogResults::CANCEL;
     108           0 :     GraphicExportOptionsDialog graphicExportOptionsDialog( Application::GetDefDialogParent(), mxSourceDocument );
     109           0 :     if (graphicExportOptionsDialog.Execute() == RET_OK )
     110             :     {
     111           0 :         maFilterDataSequence = graphicExportOptionsDialog.getFilterData();
     112           0 :         nReturn = ui::dialogs::ExecutableDialogResults::OK;
     113             :     }
     114           0 :     return nReturn;
     115             : }
     116             : 
     117             : // XEmporter
     118           0 : void GraphicExportDialog::setSourceDocument( const Reference<XComponent>& xDocument )
     119             :     throw ( IllegalArgumentException, RuntimeException )
     120             : {
     121           0 :     mxSourceDocument = xDocument;
     122             : 
     123             :     // try to set the corresponding metric unit
     124           0 :     OUString aConfigPath;
     125           0 :     Reference< XServiceInfo > xServiceInfo ( xDocument, UNO_QUERY );
     126             : 
     127           0 :     if ( xServiceInfo.is() )
     128             :     {
     129           0 :         if ( xServiceInfo->supportsService("com.sun.star.presentation.PresentationDocument") )
     130             :         {
     131           0 :             aConfigPath = OUString( "Office.Impress/Layout/Other/MeasureUnit" );
     132             :         }
     133           0 :         else if ( xServiceInfo->supportsService("com.sun.star.drawing.DrawingDocument") )
     134             :         {
     135           0 :             aConfigPath = OUString( "Office.Draw/Layout/Other/MeasureUnit" );
     136             :         }
     137           0 :         else if ( xServiceInfo->supportsService("com.sun.star.text.TextDocument") )
     138             :         {
     139           0 :             aConfigPath = OUString( "Office.Writer/Layout/Other/MeasureUnit" );
     140             :         }
     141           0 :         if ( !aConfigPath.isEmpty() )
     142             :         {
     143           0 :             FilterConfigItem aConfigItem( aConfigPath );
     144           0 :             OUString aPropertyName;
     145           0 :             SvtSysLocale aSysLocale;
     146             : 
     147           0 :             if ( aSysLocale.GetLocaleDataPtr()->getMeasurementSystemEnum() == MEASURE_METRIC )
     148             :             {
     149           0 :                 aPropertyName = OUString( "Metric" );
     150             :             }
     151             :             else
     152             :             {
     153           0 :                 aPropertyName = OUString( "NonMetric" );
     154             :             }
     155           0 :             meFieldUnit = (FieldUnit) aConfigItem.ReadInt32( aPropertyName, FUNIT_CM );
     156             :         }
     157           0 :     }
     158           0 : }
     159             : 
     160             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10