sync master with lastest vba changes
[ooovba.git] / sc / source / ui / unoobj / forbiuno.cxx
blob96c1a4cb897c384dbb5056d4443d55522d734230
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: forbiuno.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 #include <svx/forbiddencharacterstable.hxx>
38 #include "forbiuno.hxx"
39 #include "docsh.hxx"
41 using namespace ::com::sun::star;
43 //------------------------------------------------------------------------
45 vos::ORef<SvxForbiddenCharactersTable> lcl_GetForbidden( ScDocShell* pDocSh )
47 vos::ORef<SvxForbiddenCharactersTable> xRet;
48 if ( pDocSh )
50 ScDocument* pDoc = pDocSh->GetDocument();
51 xRet = pDoc->GetForbiddenCharacters();
52 if ( !xRet.isValid() )
54 // create an empty SvxForbiddenCharactersTable for SvxUnoForbiddenCharsTable,
55 // so changes can be stored.
57 xRet = new SvxForbiddenCharactersTable( pDoc->GetServiceManager() );
58 pDoc->SetForbiddenCharacters( xRet );
61 return xRet;
64 ScForbiddenCharsObj::ScForbiddenCharsObj( ScDocShell* pDocSh ) :
65 SvxUnoForbiddenCharsTable( lcl_GetForbidden( pDocSh ) ),
66 pDocShell( pDocSh )
68 if (pDocShell)
69 pDocShell->GetDocument()->AddUnoObject(*this);
72 ScForbiddenCharsObj::~ScForbiddenCharsObj()
74 if (pDocShell)
75 pDocShell->GetDocument()->RemoveUnoObject(*this);
78 void ScForbiddenCharsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
80 if ( rHint.ISA( SfxSimpleHint ) &&
81 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
83 pDocShell = NULL; // document gone
87 void ScForbiddenCharsObj::onChange()
89 if (pDocShell)
91 pDocShell->GetDocument()->SetForbiddenCharacters( mxForbiddenChars );
92 pDocShell->PostPaintGridAll();
93 pDocShell->SetDocumentModified();