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 .
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"
28 SfxAlienWarningDialog::SfxAlienWarningDialog(vcl::Window
* pParent
, const OUString
& _rFormatName
,
29 const OUString
& _rDefaultExtension
, bool rDefaultIsAlien
)
30 : MessageDialog(pParent
, "AlienWarnDialog", "sfx/ui/alienwarndialog.ui")
32 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 m_pWarningOnBox
->set_margin_left(QueryBox::GetStandardImage().GetSizePixel().Width() + 12);
37 get(m_pKeepCurrentBtn
, "save");
38 get(m_pUseDefaultFormatBtn
, "cancel");
40 OUString aExtension
= "ODF";
42 // replace formatname (text)
43 OUString sInfoText
= get_primary_text();
44 sInfoText
= sInfoText
.replaceAll( "%FORMATNAME", _rFormatName
);
45 set_primary_text(sInfoText
);
47 // replace formatname (button)
48 sInfoText
= m_pKeepCurrentBtn
->GetText();
49 sInfoText
= sInfoText
.replaceAll( "%FORMATNAME", _rFormatName
);
50 m_pKeepCurrentBtn
->SetText( sInfoText
);
52 // hide ODF explanation if default format is alien
53 // and set the proper extension in the button
56 set_secondary_text(OUString());
57 aExtension
= _rDefaultExtension
.toAsciiUpperCase();
60 // replace defaultextension (button)
61 sInfoText
= m_pUseDefaultFormatBtn
->GetText();
62 sInfoText
= sInfoText
.replaceAll( "%DEFAULTEXTENSION", aExtension
);
63 m_pUseDefaultFormatBtn
->SetText( sInfoText
);
65 // load value of "warning on" checkbox from save options
66 m_pWarningOnBox
->Check( SvtSaveOptions().IsWarnAlienFormat() );
69 SfxAlienWarningDialog::~SfxAlienWarningDialog()
74 void SfxAlienWarningDialog::dispose()
76 // save value of "warning off" checkbox, if necessary
77 SvtSaveOptions aSaveOpt
;
78 bool bChecked
= m_pWarningOnBox
->IsChecked();
79 if ( aSaveOpt
.IsWarnAlienFormat() != bChecked
)
80 aSaveOpt
.SetWarnAlienFormat( bChecked
);
81 m_pKeepCurrentBtn
.clear();
82 m_pUseDefaultFormatBtn
.clear();
83 m_pWarningOnBox
.clear();
84 MessageDialog::dispose();
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */