LCOV - code coverage report
Current view: top level - filter/source/graphic - GraphicExportDialog.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 57 1.8 %
Date: 2015-06-13 12:38:46 Functions: 2 11 18.2 %
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             : #include <unotools/syslocale.hxx>
      34             : 
      35             : using namespace css;
      36             : using namespace css::uno;
      37             : using namespace css::beans;
      38             : using namespace css::lang;
      39             : 
      40           0 : GraphicExportDialog::GraphicExportDialog( const Reference< XComponentContext >& rxContext )
      41             :     : mxContext( rxContext )
      42             :     , meFieldUnit(FUNIT_NONE)
      43           0 :     , mbExportSelection( false )
      44             : {
      45           0 : }
      46             : 
      47           0 : GraphicExportDialog::~GraphicExportDialog()
      48             : {
      49           0 : }
      50             : 
      51             : // XInitialization
      52           0 : void SAL_CALL GraphicExportDialog::initialize( const Sequence<Any>& ) throw ( Exception, RuntimeException, std::exception )
      53           0 : {}
      54             : 
      55             : // XPropertyAccess
      56           0 : Sequence<PropertyValue> GraphicExportDialog::getPropertyValues() throw ( RuntimeException, std::exception )
      57             : {
      58             :     sal_Int32 i;
      59           0 :     sal_Int32 nCount = maMediaDescriptor.getLength();
      60             : 
      61           0 :     for ( i = 0; i < nCount; i++ )
      62             :     {
      63           0 :         if ( maMediaDescriptor[ i ].Name == "FilterData" )
      64             :         {
      65           0 :             break;
      66             :         }
      67             :     }
      68             : 
      69           0 :     if ( i >= nCount )
      70             :     {
      71           0 :         nCount++;
      72           0 :         maMediaDescriptor.realloc( nCount );
      73             :     }
      74             : 
      75           0 :     maMediaDescriptor[ i ].Name = "FilterData";
      76           0 :     maMediaDescriptor[ i ].Value <<= maFilterDataSequence;
      77           0 :     return maMediaDescriptor;
      78             : }
      79             : 
      80           0 : void GraphicExportDialog::setPropertyValues( const Sequence<PropertyValue>& aProps )
      81             :     throw ( UnknownPropertyException, PropertyVetoException, IllegalArgumentException,
      82             :             WrappedTargetException, RuntimeException, std::exception )
      83             : {
      84           0 :     maMediaDescriptor = aProps;
      85             : 
      86             :     sal_Int32 i, nCount;
      87           0 :     for ( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
      88             :     {
      89           0 :         if ( maMediaDescriptor[ i ].Name == "FilterData" )
      90             :         {
      91           0 :             maMediaDescriptor[ i ].Value >>= maFilterDataSequence;
      92             :         }
      93           0 :         else if ( maMediaDescriptor[ i ].Name == "SelectionOnly" )
      94             :         {
      95           0 :             maMediaDescriptor[ i ].Value >>= mbExportSelection;
      96             :         }
      97             :     }
      98           0 : }
      99             : 
     100             : // XExecutableDialog
     101           0 : void GraphicExportDialog::setTitle( const OUString& aTitle )
     102             :     throw ( uno::RuntimeException, std::exception )
     103             : {
     104           0 :     maDialogTitle = aTitle;
     105           0 : }
     106             : 
     107           0 : sal_Int16 GraphicExportDialog::execute() throw ( RuntimeException, std::exception )
     108             : {
     109           0 :     sal_Int16 nReturn = ui::dialogs::ExecutableDialogResults::CANCEL;
     110           0 :     ScopedVclPtrInstance< GraphicExportOptionsDialog > graphicExportOptionsDialog( Application::GetDefDialogParent(), mxSourceDocument );
     111           0 :     if (graphicExportOptionsDialog->Execute() == RET_OK )
     112             :     {
     113           0 :         maFilterDataSequence = graphicExportOptionsDialog->getFilterData();
     114           0 :         nReturn = ui::dialogs::ExecutableDialogResults::OK;
     115             :     }
     116           0 :     return nReturn;
     117             : }
     118             : 
     119             : // XEmporter
     120           0 : void GraphicExportDialog::setSourceDocument( const Reference<XComponent>& xDocument )
     121             :     throw ( IllegalArgumentException, RuntimeException, std::exception )
     122             : {
     123           0 :     mxSourceDocument = xDocument;
     124             : 
     125             :     // try to set the corresponding metric unit
     126           0 :     OUString aConfigPath;
     127           0 :     Reference< XServiceInfo > xServiceInfo ( xDocument, UNO_QUERY );
     128             : 
     129           0 :     if ( xServiceInfo.is() )
     130             :     {
     131           0 :         if ( xServiceInfo->supportsService("com.sun.star.presentation.PresentationDocument") )
     132             :         {
     133           0 :             aConfigPath = "Office.Impress/Layout/Other/MeasureUnit";
     134             :         }
     135           0 :         else if ( xServiceInfo->supportsService("com.sun.star.drawing.DrawingDocument") )
     136             :         {
     137           0 :             aConfigPath = "Office.Draw/Layout/Other/MeasureUnit";
     138             :         }
     139           0 :         else if ( xServiceInfo->supportsService("com.sun.star.text.TextDocument") )
     140             :         {
     141           0 :             aConfigPath = "Office.Writer/Layout/Other/MeasureUnit";
     142             :         }
     143           0 :         if ( !aConfigPath.isEmpty() )
     144             :         {
     145           0 :             FilterConfigItem aConfigItem( aConfigPath );
     146           0 :             OUString aPropertyName;
     147           0 :             SvtSysLocale aSysLocale;
     148             : 
     149           0 :             if ( aSysLocale.GetLocaleDataPtr()->getMeasurementSystemEnum() == MEASURE_METRIC )
     150             :             {
     151           0 :                 aPropertyName = "Metric";
     152             :             }
     153             :             else
     154             :             {
     155           0 :                 aPropertyName = "NonMetric";
     156             :             }
     157           0 :             meFieldUnit = (FieldUnit) aConfigItem.ReadInt32( aPropertyName, FUNIT_CM );
     158             :         }
     159           0 :     }
     160           6 : }
     161             : 
     162             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11