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 .
20 #include <svl/whiter.hxx>
21 #include <svl/style.hxx>
22 #include <vcl/msgbox.hxx>
24 #include <sfx2/styledlg.hxx>
25 #include <sfx2/mgetempl.hxx>
26 #include "sfx2/sfxresid.hxx"
27 #include <sfx2/sfxuno.hxx>
31 // class SfxStyleDialog --------------------------------------------------
33 SfxStyleDialog::SfxStyleDialog
35 Window
* pParent
, // Parent
36 const ResId
& rResId
, // ResId
37 SfxStyleSheetBase
& rStyle
, // stylesheet to be processed
38 sal_Bool bFreeRes
, // Flag release resources
39 const String
* pUserBtnTxt
44 Constructor: Add Manage TabPage, set ExampleSet from style.
47 SfxTabDialog( pParent
, rResId
,
48 rStyle
.GetItemSet().Clone(),
49 // return TRUE also without ParentSupport , but extended
50 // to suppress the standardButton
51 rStyle
.HasParentSupport() ? sal_True
: 2,
57 AddTabPage( ID_TABPAGE_MANAGESTYLES
,
58 SfxResId( STR_TABPAGE_MANAGESTYLES
).toString(),
59 SfxManageStyleSheetPage::Create
, 0, sal_False
, 0 );
61 // With new template always set the management page as the current page
63 if( !rStyle
.GetName().Len() )
64 SetCurPageId( ID_TABPAGE_MANAGESTYLES
);
67 OUString sTxt
= OUString(GetText()) + ": " + rStyle
.GetName();
70 delete pExampleSet
; // in SfxTabDialog::Ctor() already created
71 pExampleSet
= &pStyle
->GetItemSet();
75 GetCancelButton().SetClickHdl( LINK(this, SfxStyleDialog
, CancelHdl
) );
78 // -----------------------------------------------------------------------
80 SfxStyleDialog::~SfxStyleDialog()
84 Destructor: set ExampleSet to NULL, so that SfxTabDialog does not delete
91 delete GetInputSetImpl();
94 // -----------------------------------------------------------------------
96 const SfxItemSet
* SfxStyleDialog::GetRefreshedSet()
100 This is called when <SfxTabPage::DeactivatePage(SfxItemSet *)>
101 returns <SfxTabPage::REFRESH_SET>.
105 return GetInputSetImpl();
108 // -----------------------------------------------------------------------
110 short SfxStyleDialog::Ok()
114 Overloaded, so that always RET_OK is returned.
122 // -----------------------------------------------------------------------
124 IMPL_LINK( SfxStyleDialog
, CancelHdl
, Button
*, pButton
)
128 If the dialogue was canceled, then all selected attributes must be reset
133 (void)pButton
; //unused
134 SfxTabPage
* pPage
= GetTabPage( ID_TABPAGE_MANAGESTYLES
);
136 const SfxItemSet
* pInSet
= GetInputSetImpl();
137 SfxWhichIter
aIter( *pInSet
);
138 sal_uInt16 nWhich
= aIter
.FirstWhich();
142 SfxItemState eState
= pInSet
->GetItemState( nWhich
, sal_False
);
144 if ( SFX_ITEM_DEFAULT
== eState
)
145 pExampleSet
->ClearItem( nWhich
);
147 pExampleSet
->Put( pInSet
->Get( nWhich
) );
148 nWhich
= aIter
.NextWhich();
152 pPage
->Reset( *GetInputSetImpl() );
153 EndDialog( RET_CANCEL
);
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */