1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <svtools/GraphicExportOptionsDialog.hxx>
22 using namespace css::beans
;
23 using namespace css::lang
;
24 using namespace css::uno
;
26 GraphicExportOptionsDialog::GraphicExportOptionsDialog(vcl::Window
* pWindow
, const Reference
<XComponent
>& rxSourceDocument
) :
27 ModalDialog(pWindow
, "GraphicExporter", "svt/ui/GraphicExportOptionsDialog.ui"),
29 mRenderer(rxSourceDocument
)
31 get(mpWidth
, "spin-width");
32 get(mpHeight
, "spin-height");
33 get(mpResolution
, "combo-resolution");
35 mpWidth
->SetModifyHdl( LINK( this, GraphicExportOptionsDialog
, widthModifiedHandle
));
36 mpHeight
->SetModifyHdl( LINK( this, GraphicExportOptionsDialog
, heightModifiedHandle
));
37 mpResolution
->SetModifyHdl( LINK( this, GraphicExportOptionsDialog
, resolutionModifiedHandle
));
46 GraphicExportOptionsDialog::~GraphicExportOptionsDialog()
51 void GraphicExportOptionsDialog::dispose()
56 ModalDialog::dispose();
59 void GraphicExportOptionsDialog::initialize()
61 mCurrentPage
= mRenderer
.getCurrentPageWriter();
62 mSize100mm
= mRenderer
.getDocumentSizeIn100mm(mCurrentPage
);
65 IMPL_LINK_NOARG( GraphicExportOptionsDialog
, widthModifiedHandle
)
67 mResolution
= mpWidth
->GetValue() / getViewWidthInch();
75 IMPL_LINK_NOARG( GraphicExportOptionsDialog
, heightModifiedHandle
)
77 mResolution
= mpHeight
->GetValue() / getViewHeightInch();
85 IMPL_LINK_NOARG( GraphicExportOptionsDialog
, resolutionModifiedHandle
)
87 mResolution
= mpResolution
->GetText().toInt32();
96 double GraphicExportOptionsDialog::getViewWidthInch()
98 return (double) MetricField::ConvertValue(mSize100mm
.Width(), 2, MAP_100TH_MM
, FUNIT_INCH
) / 100.0;
101 double GraphicExportOptionsDialog::getViewHeightInch()
103 return (double) MetricField::ConvertValue(mSize100mm
.Height(), 2, MAP_100TH_MM
, FUNIT_INCH
) / 100.0;
106 void GraphicExportOptionsDialog::updateWidth()
108 sal_Int32 aWidth
= (sal_Int32
)( getViewWidthInch() * mResolution
);
109 mpWidth
->SetText( OUString::number( aWidth
));
112 void GraphicExportOptionsDialog::updateHeight()
114 sal_Int32 aHeight
= (sal_Int32
)( getViewHeightInch() * mResolution
);
115 mpHeight
->SetText( OUString::number( aHeight
));
118 void GraphicExportOptionsDialog::updateResolution()
120 mpResolution
->SetText( OUString::number( (sal_Int32
) mResolution
) );
123 Sequence
<PropertyValue
> GraphicExportOptionsDialog::getFilterData()
125 sal_Int32 aWidth
= (sal_Int32
)( getViewWidthInch() * mResolution
);
126 sal_Int32 aHeight
= (sal_Int32
)( getViewHeightInch() * mResolution
);
128 Sequence
<PropertyValue
> aFilterData
;
130 aFilterData
.realloc( 2 );
131 aFilterData
[ 0 ].Name
= "PixelWidth";
132 aFilterData
[ 0 ].Value
<<= aWidth
;
133 aFilterData
[ 1 ].Name
= "PixelHeight";
134 aFilterData
[ 1 ].Value
<<= aHeight
;
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */