Bump version to 4.1-6
[LibreOffice.git] / sfx2 / source / dialog / styledlg.cxx
blobbf60f44eadf2f9b613a4378c8cea4da6aa60bd4f
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 <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>
29 #include "dialog.hrc"
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
40 ) :
42 /* [Description]
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,
52 pUserBtnTxt ),
54 pStyle( &rStyle )
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 );
65 else
67 OUString sTxt = OUString(GetText()) + ": " + rStyle.GetName();
68 SetText( sTxt );
70 delete pExampleSet; // in SfxTabDialog::Ctor() already created
71 pExampleSet = &pStyle->GetItemSet();
73 if ( bFreeRes )
74 FreeResource();
75 GetCancelButton().SetClickHdl( LINK(this, SfxStyleDialog, CancelHdl) );
78 // -----------------------------------------------------------------------
80 SfxStyleDialog::~SfxStyleDialog()
82 /* [Description]
84 Destructor: set ExampleSet to NULL, so that SfxTabDialog does not delete
85 the Set from Style.
89 pExampleSet = 0;
90 pStyle = 0;
91 delete GetInputSetImpl();
94 // -----------------------------------------------------------------------
96 const SfxItemSet* SfxStyleDialog::GetRefreshedSet()
98 /* [Description]
100 This is called when <SfxTabPage::DeactivatePage(SfxItemSet *)>
101 returns <SfxTabPage::REFRESH_SET>.
105 return GetInputSetImpl();
108 // -----------------------------------------------------------------------
110 short SfxStyleDialog::Ok()
112 /* [Description]
114 Overloaded, so that always RET_OK is returned.
118 SfxTabDialog::Ok();
119 return RET_OK;
122 // -----------------------------------------------------------------------
124 IMPL_LINK( SfxStyleDialog, CancelHdl, Button *, pButton )
126 /* [Description]
128 If the dialogue was canceled, then all selected attributes must be reset
129 again.
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();
140 while ( nWhich )
142 SfxItemState eState = pInSet->GetItemState( nWhich, sal_False );
144 if ( SFX_ITEM_DEFAULT == eState )
145 pExampleSet->ClearItem( nWhich );
146 else
147 pExampleSet->Put( pInSet->Get( nWhich ) );
148 nWhich = aIter.NextWhich();
151 if ( pPage )
152 pPage->Reset( *GetInputSetImpl() );
153 EndDialog( RET_CANCEL );
154 return 0;
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */