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 "newstyle.hrc"
27 : #include "sfx2/sfxresid.hxx"
28 :
29 : // PRIVATE METHODES ------------------------------------------------------
30 :
31 0 : IMPL_LINK( SfxNewStyleDlg, OKHdl, Control *, pControl )
32 : {
33 : (void)pControl; //unused
34 0 : const String aName( aColBox.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 : InfoBox( this, SfxResId( MSG_POOL_STYLE_NAME ) ).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 : // -----------------------------------------------------------------------
54 :
55 0 : IMPL_LINK_INLINE_START( SfxNewStyleDlg, ModifyHdl, ComboBox *, pBox )
56 : {
57 0 : aOKBtn.Enable( !comphelper::string::remove(pBox->GetText(), ' ').isEmpty() );
58 0 : return 0;
59 : }
60 0 : IMPL_LINK_INLINE_END( SfxNewStyleDlg, ModifyHdl, ComboBox *, pBox )
61 :
62 : // CTOR / DTOR -----------------------------------------------------------
63 :
64 0 : SfxNewStyleDlg::SfxNewStyleDlg( Window* pParent, SfxStyleSheetBasePool& rInPool ) :
65 :
66 : ModalDialog( pParent, SfxResId( DLG_NEW_STYLE_BY_EXAMPLE ) ),
67 :
68 : aColFL ( this, SfxResId( FL_COL ) ),
69 : aColBox ( this, SfxResId( LB_COL ) ),
70 : aOKBtn ( this, SfxResId( BT_OK ) ),
71 : aCancelBtn ( this, SfxResId( BT_CANCEL ) ),
72 : aQueryOverwriteBox ( this, SfxResId( MSG_OVERWRITE ) ),
73 :
74 0 : rPool( rInPool )
75 :
76 : {
77 0 : FreeResource();
78 :
79 0 : aOKBtn.SetClickHdl(LINK(this, SfxNewStyleDlg, OKHdl));
80 0 : aColBox.SetModifyHdl(LINK(this, SfxNewStyleDlg, ModifyHdl));
81 0 : aColBox.SetDoubleClickHdl(LINK(this, SfxNewStyleDlg, OKHdl));
82 : // aColBox.SetAccessibleName(SfxResId(FL_COL).toString());
83 :
84 0 : SfxStyleSheetBase *pStyle = rPool.First();
85 0 : while ( pStyle )
86 : {
87 0 : aColBox.InsertEntry(pStyle->GetName());
88 0 : pStyle = rPool.Next();
89 : }
90 0 : }
91 :
92 : // -----------------------------------------------------------------------
93 :
94 0 : SfxNewStyleDlg::~SfxNewStyleDlg()
95 : {
96 0 : }
97 :
98 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|