Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / app / msgpool.cxx
blobc4efedbf50cc948c3e2f04d5831ebb22375b5bb1
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 "scitems.hxx"
21 #include <svx/dialogs.hrc>
23 #include "sc.hrc"
24 #include "docpool.hxx"
25 #include "msgpool.hxx"
27 //------------------------------------------------------------------------
29 static SfxItemInfo const aMsgItemInfos[] =
31 { 0, SFX_ITEM_POOLABLE }, // SCITEM_STRING
32 { 0, SFX_ITEM_POOLABLE }, // SCITEM_SEARCHDATA - nicht mehr benutzt !!!
33 { SID_SORT, SFX_ITEM_POOLABLE }, // SCITEM_SORTDATA
34 { SID_QUERY, SFX_ITEM_POOLABLE }, // SCITEM_QUERYDATA
35 { SID_SUBTOTALS, SFX_ITEM_POOLABLE }, // SCITEM_SUBTDATA
36 { SID_CONSOLIDATE, SFX_ITEM_POOLABLE }, // SCITEM_CONSOLIDATEDATA
37 { SID_PIVOT_TABLE, SFX_ITEM_POOLABLE }, // SCITEM_PIVOTDATA
38 { SID_SOLVE, SFX_ITEM_POOLABLE }, // SCITEM_SOLVEDATA
39 { SID_SCUSERLISTS, SFX_ITEM_POOLABLE }, // SCITEM_USERLIST
40 { SID_PRINTER_NOTFOUND_WARN, SFX_ITEM_POOLABLE } // SCITEM_PRINTWARN
43 //------------------------------------------------------------------------
45 ScMessagePool::ScMessagePool()
46 : SfxItemPool ( OUString("ScMessagePool"),
47 MSGPOOL_START, MSGPOOL_END,
48 aMsgItemInfos, NULL ),
50 aGlobalStringItem ( SfxStringItem ( SCITEM_STRING, OUString() ) ),
51 aGlobalSearchItem ( SvxSearchItem ( SCITEM_SEARCHDATA ) ),
52 aGlobalSortItem ( ScSortItem ( SCITEM_SORTDATA, NULL ) ),
53 aGlobalQueryItem ( ScQueryItem ( SCITEM_QUERYDATA, NULL, NULL ) ),
54 aGlobalSubTotalItem ( ScSubTotalItem ( SCITEM_SUBTDATA, NULL, NULL ) ),
55 aGlobalConsolidateItem ( ScConsolidateItem ( SCITEM_CONSOLIDATEDATA, NULL ) ),
56 aGlobalPivotItem ( ScPivotItem ( SCITEM_PIVOTDATA, NULL, NULL, false ) ),
57 aGlobalSolveItem ( ScSolveItem ( SCITEM_SOLVEDATA, NULL ) ),
58 aGlobalUserListItem ( ScUserListItem ( SCITEM_USERLIST ) ),
60 aPrintWarnItem ( SfxBoolItem ( SCITEM_PRINTWARN, false ) )
62 ppPoolDefaults = new SfxPoolItem*[MSGPOOL_END - MSGPOOL_START + 1];
64 ppPoolDefaults[SCITEM_STRING - MSGPOOL_START] = &aGlobalStringItem;
65 ppPoolDefaults[SCITEM_SEARCHDATA - MSGPOOL_START] = &aGlobalSearchItem;
66 ppPoolDefaults[SCITEM_SORTDATA - MSGPOOL_START] = &aGlobalSortItem;
67 ppPoolDefaults[SCITEM_QUERYDATA - MSGPOOL_START] = &aGlobalQueryItem;
68 ppPoolDefaults[SCITEM_SUBTDATA - MSGPOOL_START] = &aGlobalSubTotalItem;
69 ppPoolDefaults[SCITEM_CONSOLIDATEDATA - MSGPOOL_START] = &aGlobalConsolidateItem;
70 ppPoolDefaults[SCITEM_PIVOTDATA - MSGPOOL_START] = &aGlobalPivotItem;
71 ppPoolDefaults[SCITEM_SOLVEDATA - MSGPOOL_START] = &aGlobalSolveItem;
72 ppPoolDefaults[SCITEM_USERLIST - MSGPOOL_START] = &aGlobalUserListItem;
73 ppPoolDefaults[SCITEM_PRINTWARN - MSGPOOL_START] = &aPrintWarnItem;
75 SetDefaults( ppPoolDefaults );
77 pDocPool = new ScDocumentPool;
79 SetSecondaryPool( pDocPool );
83 ScMessagePool::~ScMessagePool()
85 Delete();
86 SetSecondaryPool( NULL ); // before deleting defaults (accesses defaults)
88 for ( sal_uInt16 i=0; i <= MSGPOOL_END-MSGPOOL_START; i++ )
89 SetRefCount( *ppPoolDefaults[i], 0 );
91 delete[] ppPoolDefaults;
93 SfxItemPool::Free(pDocPool);
97 SfxMapUnit ScMessagePool::GetMetric( sal_uInt16 nWhich ) const
99 // eigene Attribute: Twips, alles andere 1/100 mm
101 if ( nWhich >= ATTR_STARTINDEX && nWhich <= ATTR_ENDINDEX )
102 return SFX_MAPUNIT_TWIP;
103 else
104 return SFX_MAPUNIT_100TH_MM;
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */