bump product version to 4.1.6.2
[LibreOffice.git] / filter / source / graphic / GraphicExportDialog.cxx
blob9d3af13b744b797a56994b008871ec81b94395de
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "GraphicExportDialog.hxx"
22 #include <vcl/graphicfilter.hxx>
23 #include <vcl/svapp.hxx>
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>
32 #include <svtools/GraphicExportOptionsDialog.hxx>
34 using namespace css;
35 using namespace css::uno;
36 using namespace css::beans;
37 using namespace css::lang;
39 GraphicExportDialog::GraphicExportDialog( const Reference< XComponentContext >& rxContext ) :
40 mxContext ( rxContext ),
41 mbExportSelection ( sal_False )
45 GraphicExportDialog::~GraphicExportDialog()
49 // XInitialization
50 void SAL_CALL GraphicExportDialog::initialize( const Sequence<Any>& ) throw ( Exception, RuntimeException )
53 // XPropertyAccess
54 Sequence<PropertyValue> GraphicExportDialog::getPropertyValues() throw ( RuntimeException )
56 sal_Int32 i;
57 sal_Int32 nCount = maMediaDescriptor.getLength();
59 for ( i = 0; i < nCount; i++ )
61 if ( maMediaDescriptor[ i ].Name == "FilterData" )
63 break;
67 if ( i >= nCount )
69 nCount++;
70 maMediaDescriptor.realloc( nCount );
73 maMediaDescriptor[ i ].Name = OUString( "FilterData" );
74 maMediaDescriptor[ i ].Value <<= maFilterDataSequence;
75 return maMediaDescriptor;
78 void GraphicExportDialog::setPropertyValues( const Sequence<PropertyValue>& aProps )
79 throw ( UnknownPropertyException, PropertyVetoException, IllegalArgumentException,
80 WrappedTargetException, RuntimeException )
82 maMediaDescriptor = aProps;
84 sal_Int32 i, nCount;
85 for ( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
87 if ( maMediaDescriptor[ i ].Name == "FilterData" )
89 maMediaDescriptor[ i ].Value >>= maFilterDataSequence;
91 else if ( maMediaDescriptor[ i ].Name == "SelectionOnly" )
93 maMediaDescriptor[ i ].Value >>= mbExportSelection;
98 // XExecutableDialog
99 void GraphicExportDialog::setTitle( const OUString& aTitle )
100 throw ( uno::RuntimeException )
102 maDialogTitle = aTitle;
105 sal_Int16 GraphicExportDialog::execute() throw ( RuntimeException )
107 sal_Int16 nReturn = ui::dialogs::ExecutableDialogResults::CANCEL;
108 GraphicExportOptionsDialog graphicExportOptionsDialog( Application::GetDefDialogParent(), mxSourceDocument );
109 if (graphicExportOptionsDialog.Execute() == RET_OK )
111 maFilterDataSequence = graphicExportOptionsDialog.getFilterData();
112 nReturn = ui::dialogs::ExecutableDialogResults::OK;
114 return nReturn;
117 // XEmporter
118 void GraphicExportDialog::setSourceDocument( const Reference<XComponent>& xDocument )
119 throw ( IllegalArgumentException, RuntimeException )
121 mxSourceDocument = xDocument;
123 // try to set the corresponding metric unit
124 OUString aConfigPath;
125 Reference< XServiceInfo > xServiceInfo ( xDocument, UNO_QUERY );
127 if ( xServiceInfo.is() )
129 if ( xServiceInfo->supportsService( OUString( "com.sun.star.presentation.PresentationDocument" ) ) )
131 aConfigPath = OUString( "Office.Impress/Layout/Other/MeasureUnit" );
133 else if ( xServiceInfo->supportsService( OUString( "com.sun.star.drawing.DrawingDocument" ) ) )
135 aConfigPath = OUString( "Office.Draw/Layout/Other/MeasureUnit" );
137 else if ( xServiceInfo->supportsService( OUString( "com.sun.star.text.TextDocument" ) ) )
139 aConfigPath = OUString( "Office.Writer/Layout/Other/MeasureUnit" );
141 if ( !aConfigPath.isEmpty() )
143 FilterConfigItem aConfigItem( aConfigPath );
144 OUString aPropertyName;
145 SvtSysLocale aSysLocale;
147 if ( aSysLocale.GetLocaleDataPtr()->getMeasurementSystemEnum() == MEASURE_METRIC )
149 aPropertyName = OUString( "Metric" );
151 else
153 aPropertyName = OUString( "NonMetric" );
155 meFieldUnit = (FieldUnit) aConfigItem.ReadInt32( aPropertyName, FUNIT_CM );
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */