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 :
21 : #include <sal/macros.h>
22 : #include <sfx2/sfxresid.hxx>
23 : #include <sfx2/sfxuno.hxx>
24 : #include <unotools/saveopt.hxx>
25 : #include <vcl/msgbox.hxx>
26 : #include "alienwarn.hxx"
27 :
28 0 : SfxAlienWarningDialog::SfxAlienWarningDialog(vcl::Window* pParent, const OUString& _rFormatName,
29 : const OUString& _rDefaultExtension, bool rDefaultIsAlien)
30 0 : : MessageDialog(pParent, "AlienWarnDialog", "sfx/ui/alienwarndialog.ui")
31 : {
32 0 : get(m_pWarningOnBox, "ask");
33 : //fdo#75121, a bit tricky because the widgets we want to align with
34 : //don't actually exist in the ui description, they're implied
35 0 : m_pWarningOnBox->set_margin_left(QueryBox::GetStandardImage().GetSizePixel().Width() + 12);
36 :
37 0 : get(m_pKeepCurrentBtn, "save");
38 0 : get(m_pUseDefaultFormatBtn, "cancel");
39 :
40 0 : OUString aExtension = "ODF";
41 :
42 : // replace formatname (text)
43 0 : OUString sInfoText = get_primary_text();
44 0 : sInfoText = sInfoText.replaceAll( "%FORMATNAME", _rFormatName );
45 0 : set_primary_text(sInfoText);
46 :
47 : // replace formatname (button)
48 0 : sInfoText = m_pKeepCurrentBtn->GetText();
49 0 : sInfoText = sInfoText.replaceAll( "%FORMATNAME", _rFormatName );
50 0 : m_pKeepCurrentBtn->SetText( sInfoText );
51 :
52 : // hide ODF explanation if default format is alien
53 : // and set the proper extension in the button
54 0 : if( rDefaultIsAlien )
55 : {
56 0 : set_secondary_text(OUString());
57 0 : aExtension = _rDefaultExtension.toAsciiUpperCase();
58 : }
59 :
60 : // replace defaultextension (button)
61 0 : sInfoText = m_pUseDefaultFormatBtn->GetText();
62 0 : sInfoText = sInfoText.replaceAll( "%DEFAULTEXTENSION", aExtension );
63 0 : m_pUseDefaultFormatBtn->SetText( sInfoText );
64 :
65 : // load value of "warning on" checkbox from save options
66 0 : m_pWarningOnBox->Check( SvtSaveOptions().IsWarnAlienFormat() );
67 0 : }
68 :
69 0 : SfxAlienWarningDialog::~SfxAlienWarningDialog()
70 : {
71 0 : disposeOnce();
72 0 : }
73 :
74 0 : void SfxAlienWarningDialog::dispose()
75 : {
76 : // save value of "warning off" checkbox, if necessary
77 0 : SvtSaveOptions aSaveOpt;
78 0 : bool bChecked = m_pWarningOnBox->IsChecked();
79 0 : if ( aSaveOpt.IsWarnAlienFormat() != bChecked )
80 0 : aSaveOpt.SetWarnAlienFormat( bChecked );
81 0 : m_pKeepCurrentBtn.clear();
82 0 : m_pUseDefaultFormatBtn.clear();
83 0 : m_pWarningOnBox.clear();
84 0 : MessageDialog::dispose();
85 648 : }
86 :
87 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|