Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / sfx2 / source / dialog / styledlg.cxx
blob2fbdd661d7f3fdfe5e28206f306acb973ff4a7d1
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>
40 #include "dialog.hrc"
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
51 ) :
53 /* [Description]
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,
63 pUserBtnTxt ),
65 pStyle( &rStyle )
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 );
76 else
78 String sTxt( GetText() );
79 sTxt += DEFINE_CONST_UNICODE(": ") ;
80 sTxt += rStyle.GetName();
81 SetText( sTxt );
83 delete pExampleSet; // in SfxTabDialog::Ctor() already created
84 pExampleSet = &pStyle->GetItemSet();
86 if ( bFreeRes )
87 FreeResource();
88 GetCancelButton().SetClickHdl( LINK(this, SfxStyleDialog, CancelHdl) );
91 // -----------------------------------------------------------------------
93 SfxStyleDialog::~SfxStyleDialog()
95 /* [Description]
97 Destructor: set ExampleSet to NULL, so that SfxTabDialog does not delete
98 the Set from Style.
102 pExampleSet = 0;
103 pStyle = 0;
104 delete GetInputSetImpl();
107 // -----------------------------------------------------------------------
109 const SfxItemSet* SfxStyleDialog::GetRefreshedSet()
111 /* [Description]
113 This is called when <SfxTabPage::DeactivatePage(SfxItemSet *)>
114 returns <SfxTabPage::REFRESH_SET>.
118 return GetInputSetImpl();
121 // -----------------------------------------------------------------------
123 short SfxStyleDialog::Ok()
125 /* [Description]
127 Overloaded, so that always RET_OK is returned.
131 SfxTabDialog::Ok();
132 return RET_OK;
135 // -----------------------------------------------------------------------
137 IMPL_LINK( SfxStyleDialog, CancelHdl, Button *, pButton )
139 /* [Description]
141 If the dialogue was canceled, then all selected attributes must be reset
142 again.
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();
153 while ( nWhich )
155 SfxItemState eState = pInSet->GetItemState( nWhich, sal_False );
157 if ( SFX_ITEM_DEFAULT == eState )
158 pExampleSet->ClearItem( nWhich );
159 else
160 pExampleSet->Put( pInSet->Get( nWhich ) );
161 nWhich = aIter.NextWhich();
164 if ( pPage )
165 pPage->Reset( *GetInputSetImpl() );
166 EndDialog( RET_CANCEL );
167 return 0;
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */