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 : #include <comphelper/string.hxx>
21 :
22 : #include <svl/style.hxx>
23 :
24 : #include <sfx2/newstyle.hxx>
25 : #include "dialog.hrc"
26 : #include <sfx2/sfxresid.hxx>
27 : #include <vcl/layout.hxx>
28 :
29 : // PRIVATE METHODES ------------------------------------------------------
30 :
31 0 : IMPL_LINK( SfxNewStyleDlg, OKHdl, Control *, pControl )
32 : {
33 : (void)pControl; //unused
34 0 : const OUString aName( m_pColBox->GetText() );
35 0 : SfxStyleSheetBase* pStyle = rPool.Find( aName, rPool.GetSearchFamily(), SFXSTYLEBIT_ALL );
36 0 : if ( pStyle )
37 : {
38 0 : if ( !pStyle->IsUserDefined() )
39 : {
40 0 : MessageDialog( this, SfxResId( STR_POOL_STYLE_NAME ), VCL_MESSAGE_INFO ).Execute();
41 0 : return 0;
42 : }
43 :
44 0 : if ( RET_YES == aQueryOverwriteBox.Execute() )
45 0 : EndDialog( RET_OK );
46 : }
47 : else
48 0 : EndDialog( RET_OK );
49 :
50 0 : return 0;
51 : }
52 :
53 0 : IMPL_LINK_INLINE_START( SfxNewStyleDlg, ModifyHdl, ComboBox *, pBox )
54 : {
55 0 : m_pOKBtn->Enable( !comphelper::string::remove(pBox->GetText(), ' ').isEmpty() );
56 0 : return 0;
57 : }
58 0 : IMPL_LINK_INLINE_END( SfxNewStyleDlg, ModifyHdl, ComboBox *, pBox )
59 :
60 0 : SfxNewStyleDlg::SfxNewStyleDlg( vcl::Window* pParent, SfxStyleSheetBasePool& rInPool )
61 : : ModalDialog(pParent, "CreateStyleDialog", "sfx/ui/newstyle.ui")
62 : , aQueryOverwriteBox(this, SfxResId(STR_QUERY_OVERWRITE),
63 : VCL_MESSAGE_QUESTION, VCL_BUTTONS_YES_NO)
64 0 : , rPool(rInPool)
65 : {
66 0 : get(m_pColBox, "stylename");
67 0 : m_pColBox->set_width_request(m_pColBox->approximate_char_width() * 25);
68 0 : m_pColBox->set_height_request(m_pColBox->GetTextHeight() * 10);
69 0 : get(m_pOKBtn, "ok");
70 :
71 0 : m_pOKBtn->SetClickHdl(LINK(this, SfxNewStyleDlg, OKHdl));
72 0 : m_pColBox->SetModifyHdl(LINK(this, SfxNewStyleDlg, ModifyHdl));
73 0 : m_pColBox->SetDoubleClickHdl(LINK(this, SfxNewStyleDlg, OKHdl));
74 :
75 0 : SfxStyleSheetBase *pStyle = rPool.First();
76 0 : while ( pStyle )
77 : {
78 0 : m_pColBox->InsertEntry(pStyle->GetName());
79 0 : pStyle = rPool.Next();
80 : }
81 0 : }
82 :
83 0 : SfxNewStyleDlg::~SfxNewStyleDlg()
84 : {
85 951 : }
86 :
87 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|