1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 // include ---------------------------------------------------------------
31 #include <svl/whiter.hxx>
32 #include <svl/style.hxx>
33 #include <vcl/msgbox.hxx>
35 #include <sfx2/styledlg.hxx>
36 #include <sfx2/mgetempl.hxx>
37 #include "sfx2/sfxresid.hxx"
38 #include <sfx2/sfxuno.hxx>
42 // class SfxStyleDialog --------------------------------------------------
44 SfxStyleDialog::SfxStyleDialog
46 Window
* pParent
, // Parent
47 const ResId
& rResId
, // ResId
48 SfxStyleSheetBase
& rStyle
, // stylesheet to be processed
49 sal_Bool bFreeRes
, // Flag release resources
50 const String
* pUserBtnTxt
55 Constructor: Add Manage TabPage, set ExampleSet from style.
58 SfxTabDialog( pParent
, rResId
,
59 rStyle
.GetItemSet().Clone(),
60 // return TRUE also without ParentSupport , but extended
61 // to suppress the standardButton
62 rStyle
.HasParentSupport() ? sal_True
: 2,
68 AddTabPage( ID_TABPAGE_MANAGESTYLES
,
69 String( SfxResId( STR_TABPAGE_MANAGESTYLES
) ),
70 SfxManageStyleSheetPage::Create
, 0, sal_False
, 0 );
72 // With new template always set the management page as the current page
74 if( !rStyle
.GetName().Len() )
75 SetCurPageId( ID_TABPAGE_MANAGESTYLES
);
78 String
sTxt( GetText() );
79 sTxt
+= DEFINE_CONST_UNICODE(": ") ;
80 sTxt
+= rStyle
.GetName();
83 delete pExampleSet
; // in SfxTabDialog::Ctor() already created
84 pExampleSet
= &pStyle
->GetItemSet();
88 GetCancelButton().SetClickHdl( LINK(this, SfxStyleDialog
, CancelHdl
) );
91 // -----------------------------------------------------------------------
93 SfxStyleDialog::~SfxStyleDialog()
97 Destructor: set ExampleSet to NULL, so that SfxTabDialog does not delete
104 delete GetInputSetImpl();
107 // -----------------------------------------------------------------------
109 const SfxItemSet
* SfxStyleDialog::GetRefreshedSet()
113 This is called when <SfxTabPage::DeactivatePage(SfxItemSet *)>
114 returns <SfxTabPage::REFRESH_SET>.
118 return GetInputSetImpl();
121 // -----------------------------------------------------------------------
123 short SfxStyleDialog::Ok()
127 Overloaded, so that always RET_OK is returned.
135 // -----------------------------------------------------------------------
137 IMPL_LINK( SfxStyleDialog
, CancelHdl
, Button
*, pButton
)
141 If the dialogue was canceled, then all selected attributes must be reset
146 (void)pButton
; //unused
147 SfxTabPage
* pPage
= GetTabPage( ID_TABPAGE_MANAGESTYLES
);
149 const SfxItemSet
* pInSet
= GetInputSetImpl();
150 SfxWhichIter
aIter( *pInSet
);
151 sal_uInt16 nWhich
= aIter
.FirstWhich();
155 SfxItemState eState
= pInSet
->GetItemState( nWhich
, sal_False
);
157 if ( SFX_ITEM_DEFAULT
== eState
)
158 pExampleSet
->ClearItem( nWhich
);
160 pExampleSet
->Put( pInSet
->Get( nWhich
) );
161 nWhich
= aIter
.NextWhich();
165 pPage
->Reset( *GetInputSetImpl() );
166 EndDialog( RET_CANCEL
);
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */