bump product version to 5.0.4.1
[LibreOffice.git] / sfx2 / source / dialog / newstyle.cxx
blob464d12a6a5b36a0034b0b9e31f9c12a2ee7a2081
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <comphelper/string.hxx>
22 #include <svl/style.hxx>
24 #include <sfx2/newstyle.hxx>
25 #include "dialog.hrc"
26 #include <sfx2/sfxresid.hxx>
27 #include <vcl/layout.hxx>
29 // PRIVATE METHODES ------------------------------------------------------
31 IMPL_LINK( SfxNewStyleDlg, OKHdl, Control *, pControl )
33 (void)pControl; //unused
34 const OUString aName( m_pColBox->GetText() );
35 SfxStyleSheetBase* pStyle = rPool.Find( aName, rPool.GetSearchFamily(), SFXSTYLEBIT_ALL );
36 if ( pStyle )
38 if ( !pStyle->IsUserDefined() )
40 ScopedVclPtrInstance<MessageDialog>::Create( this, SfxResId( STR_POOL_STYLE_NAME ), VCL_MESSAGE_INFO )->Execute();
41 return 0;
44 if ( RET_YES == aQueryOverwriteBox->Execute() )
45 EndDialog( RET_OK );
47 else
48 EndDialog( RET_OK );
50 return 0;
53 IMPL_LINK( SfxNewStyleDlg, ModifyHdl, ComboBox *, pBox )
55 m_pOKBtn->Enable( !comphelper::string::remove(pBox->GetText(), ' ').isEmpty() );
56 return 0;
59 SfxNewStyleDlg::SfxNewStyleDlg( vcl::Window* pParent, SfxStyleSheetBasePool& rInPool )
60 : ModalDialog(pParent, "CreateStyleDialog", "sfx/ui/newstyle.ui")
61 , aQueryOverwriteBox(VclPtr<MessageDialog>::Create(this, SfxResId(STR_QUERY_OVERWRITE),
62 VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO))
63 , rPool(rInPool)
65 get(m_pColBox, "stylename");
66 m_pColBox->set_width_request(m_pColBox->approximate_char_width() * 25);
67 m_pColBox->set_height_request(m_pColBox->GetTextHeight() * 10);
68 get(m_pOKBtn, "ok");
70 m_pOKBtn->SetClickHdl(LINK(this, SfxNewStyleDlg, OKHdl));
71 m_pColBox->SetModifyHdl(LINK(this, SfxNewStyleDlg, ModifyHdl));
72 m_pColBox->SetDoubleClickHdl(LINK(this, SfxNewStyleDlg, OKHdl));
74 SfxStyleSheetBase *pStyle = rPool.First();
75 while ( pStyle )
77 m_pColBox->InsertEntry(pStyle->GetName());
78 pStyle = rPool.Next();
82 SfxNewStyleDlg::~SfxNewStyleDlg()
84 disposeOnce();
87 void SfxNewStyleDlg::dispose()
89 aQueryOverwriteBox.disposeAndClear();
90 m_pColBox.clear();
91 m_pOKBtn.clear();
92 ModalDialog::dispose();
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */