1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_filter.hxx"
24 
25 #include "impsvgdialog.hxx"
26 #include <cstdio>
27 
28 using namespace rtl;
29 using namespace com::sun::star::uno;
30 using namespace com::sun::star::beans;
31 
implMap(Window &,sal_Int32 nVal)32 inline sal_Int32 implMap( Window& /*rWnd*/, sal_Int32 nVal )
33 {
34     //return( rWnd.LogicToLogic( Size( nVal, nVal ) ).Height(), MAP_APPFONT, MAP_APPFONT );
35     return( nVal << 1 );
36 }
37 
38 // ----------------
39 // - ImpSVGDialog -
40 // ----------------
41 
ImpSVGDialog(Window * pParent,Sequence<PropertyValue> & rFilterData)42 ImpSVGDialog::ImpSVGDialog( Window* pParent/*, ResMgr& rResMgr*/, Sequence< PropertyValue >& rFilterData ) :
43     ModalDialog( pParent/*KA, ResId( DLG_OPTIONS, &rResMgr*/ ),
44     maFI( this ),
45     maCBTinyProfile( this ),
46     maCBEmbedFonts( this ),
47     maCBUseNativeDecoration( this ),
48     maBTOK( this, WB_DEF_OK ),
49     maBTCancel( this ),
50     maBTHelp( this ),
51     maConfigItem( String( RTL_CONSTASCII_USTRINGPARAM( SVG_EXPORTFILTER_CONFIGPATH ) ), &rFilterData ),
52     mbOldNativeDecoration( sal_False )
53 {
54     SetText( String( RTL_CONSTASCII_USTRINGPARAM( "SVG Export Options" ) ) );
55     SetOutputSizePixel( Size( implMap( *this, 177 ), implMap( *this, 77 ) ) );
56 
57     maFI.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Export" ) ) );
58     maFI.SetPosSizePixel( Point( implMap( *this, 6 ), implMap( *this, 3 ) ),
59                                  Size( implMap( *this, 165 ), implMap( *this, 8 ) ) );
60 
61     maCBTinyProfile.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Use SVG Tiny profile" ) ) );
62     maCBTinyProfile.SetPosSizePixel( Point( implMap( *this, 12 ), implMap( *this, 14 ) ),
63                                      Size( implMap( *this, 142 ), implMap( *this, 10 ) ) );
64 
65     maCBEmbedFonts.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Embed fonts" ) ) );
66     maCBEmbedFonts.SetPosSizePixel( Point( implMap( *this, 12 ), implMap( *this, 27 ) ),
67                                     Size( implMap( *this, 142 ), implMap( *this, 10 ) ) );
68 
69     maCBUseNativeDecoration.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Use SVG native text decoration" ) ) );
70     maCBUseNativeDecoration.SetPosSizePixel( Point( implMap( *this, 12 ), implMap( *this, 41 ) ),
71                                              Size( implMap( *this, 142 ), implMap( *this, 10 ) ) );
72 
73     maCBTinyProfile.Check( maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_TINYPROFILE ) ), sal_False ) );
74     maCBEmbedFonts.Check( maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_EMBEDFONTS ) ), sal_True ) );
75     maCBUseNativeDecoration.Check( maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_NATIVEDECORATION ) ), sal_True ) );
76 
77     maBTOK.SetPosSizePixel( Point( implMap( *this, 12 ), implMap( *this, 57 ) ),
78                             Size( implMap( *this, 50 ), implMap( *this, 14 ) ) );
79     maBTCancel.SetPosSizePixel( Point( implMap( *this, 65 ), implMap( *this, 57 ) ),
80                                 Size( implMap( *this, 50 ), implMap( *this, 14 ) ) );
81     maBTHelp.SetPosSizePixel( Point( implMap( *this, 121 ), implMap( *this, 57 ) ),
82                               Size( implMap( *this, 50 ), implMap( *this, 14 ) ) );
83 
84     maCBTinyProfile.SetToggleHdl( LINK( this, ImpSVGDialog, OnToggleCheckbox ) );
85     OnToggleCheckbox( &maCBTinyProfile );
86 
87     maFI.Show();
88 
89     maCBTinyProfile.Show();
90     maCBEmbedFonts.Show();
91     maCBUseNativeDecoration.Show();
92 
93     maBTOK.Show();
94     maBTCancel.Show();
95     maBTHelp.Show();
96 }
97 
98 // -----------------------------------------------------------------------------
99 
~ImpSVGDialog()100 ImpSVGDialog::~ImpSVGDialog()
101 {
102 }
103 
104 // -----------------------------------------------------------------------------
105 
GetFilterData()106 Sequence< PropertyValue > ImpSVGDialog::GetFilterData()
107 {
108     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_TINYPROFILE ) ), maCBTinyProfile.IsChecked() );
109     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_EMBEDFONTS ) ), maCBEmbedFonts.IsChecked() );
110 	maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( SVG_PROP_NATIVEDECORATION ) ), maCBUseNativeDecoration.IsChecked() );
111 
112     return( maConfigItem.GetFilterData() );
113 }
114 
115 // -----------------------------------------------------------------------------
116 
IMPL_LINK(ImpSVGDialog,OnToggleCheckbox,CheckBox *,pBox)117 IMPL_LINK( ImpSVGDialog, OnToggleCheckbox, CheckBox*, pBox )
118 {
119     if( pBox == &maCBTinyProfile )
120     {
121         if( pBox->IsChecked() )
122         {
123             mbOldNativeDecoration = maCBUseNativeDecoration.IsChecked();
124 
125             maCBUseNativeDecoration.Check( sal_False );
126             maCBUseNativeDecoration.Disable();
127         }
128         else
129         {
130             maCBUseNativeDecoration.Enable();
131             maCBUseNativeDecoration.Check( mbOldNativeDecoration );
132         }
133     }
134 
135     return 0;
136 }
137