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 <svtools/GraphicExportOptionsDialog.hxx>
21 :
22 : using namespace css::beans;
23 : using namespace css::lang;
24 : using namespace css::uno;
25 :
26 0 : GraphicExportOptionsDialog::GraphicExportOptionsDialog(Window* pWindow, const Reference<XComponent>& rxSourceDocument) :
27 : ModalDialog(pWindow, "GraphicExporter", "svt/ui/GraphicExportOptionsDialog.ui"),
28 : mResolution(96.0),
29 0 : mRenderer(rxSourceDocument)
30 : {
31 0 : get(mpWidth, "spin-width");
32 0 : get(mpHeight, "spin-height");
33 0 : get(mpResolution, "combo-resolution");
34 :
35 0 : mpWidth->SetModifyHdl( LINK( this, GraphicExportOptionsDialog, widthModifiedHandle ));
36 0 : mpHeight->SetModifyHdl( LINK( this, GraphicExportOptionsDialog, heightModifiedHandle ));
37 0 : mpResolution->SetModifyHdl( LINK( this, GraphicExportOptionsDialog, resolutionModifiedHandle ));
38 :
39 0 : initialize();
40 :
41 0 : updateWidth();
42 0 : updateHeight();
43 0 : updateResolution();
44 0 : }
45 :
46 0 : GraphicExportOptionsDialog::~GraphicExportOptionsDialog()
47 0 : {}
48 :
49 0 : void GraphicExportOptionsDialog::initialize()
50 : {
51 0 : mCurrentPage = mRenderer.getCurrentPageWriter();
52 0 : mSize100mm = mRenderer.getDocumentSizeIn100mm(mCurrentPage);
53 0 : }
54 :
55 0 : IMPL_LINK_NOARG( GraphicExportOptionsDialog, widthModifiedHandle )
56 : {
57 0 : mResolution = mpWidth->GetValue() / getViewWidthInch();
58 :
59 0 : updateHeight();
60 0 : updateResolution();
61 :
62 0 : return 0L;
63 : }
64 :
65 0 : IMPL_LINK_NOARG( GraphicExportOptionsDialog, heightModifiedHandle )
66 : {
67 0 : mResolution = mpHeight->GetValue() / getViewHeightInch();
68 :
69 0 : updateWidth();
70 0 : updateResolution();
71 :
72 0 : return 0L;
73 : }
74 :
75 0 : IMPL_LINK_NOARG( GraphicExportOptionsDialog, resolutionModifiedHandle )
76 : {
77 0 : mResolution = mpResolution->GetText().toInt32();
78 :
79 0 : updateWidth();
80 0 : updateHeight();
81 0 : Update();
82 :
83 0 : return 0L;
84 : }
85 :
86 0 : double GraphicExportOptionsDialog::getViewWidthInch()
87 : {
88 0 : return (double) MetricField::ConvertValue(mSize100mm.Width(), 2, MAP_100TH_MM, FUNIT_INCH) / 100.0;
89 : }
90 :
91 0 : double GraphicExportOptionsDialog::getViewHeightInch()
92 : {
93 0 : return (double) MetricField::ConvertValue(mSize100mm.Height(), 2, MAP_100TH_MM, FUNIT_INCH) / 100.0;
94 : }
95 :
96 0 : void GraphicExportOptionsDialog::updateWidth()
97 : {
98 0 : sal_Int32 aWidth = (sal_Int32)( getViewWidthInch() * mResolution );
99 0 : mpWidth->SetText( OUString::number( aWidth ));
100 0 : }
101 :
102 0 : void GraphicExportOptionsDialog::updateHeight()
103 : {
104 0 : sal_Int32 aHeight = (sal_Int32)( getViewHeightInch() * mResolution );
105 0 : mpHeight->SetText( OUString::number( aHeight ));
106 0 : }
107 :
108 0 : void GraphicExportOptionsDialog::updateResolution()
109 : {
110 0 : mpResolution->SetText( OUString::number( (sal_Int32) mResolution ) );
111 0 : }
112 :
113 0 : Sequence<PropertyValue> GraphicExportOptionsDialog::getFilterData()
114 : {
115 0 : sal_Int32 aWidth = (sal_Int32)( getViewWidthInch() * mResolution );
116 0 : sal_Int32 aHeight = (sal_Int32)( getViewHeightInch() * mResolution );
117 :
118 0 : Sequence<PropertyValue> aFilterData;
119 :
120 0 : aFilterData.realloc( 2 );
121 0 : aFilterData[ 0 ].Name = "PixelWidth";
122 0 : aFilterData[ 0 ].Value <<= aWidth;
123 0 : aFilterData[ 1 ].Name = "PixelHeight";
124 0 : aFilterData[ 1 ].Value <<= aHeight;
125 :
126 0 : return aFilterData;
127 513 : }
128 :
129 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|