Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "scitems.hxx"
21 : #include <svx/dialogs.hrc>
22 :
23 : #include "sc.hrc"
24 : #include "docpool.hxx"
25 : #include "msgpool.hxx"
26 :
27 : static SfxItemInfo const aMsgItemInfos[] =
28 : {
29 : { 0, SFX_ITEM_POOLABLE }, // SCITEM_STRING
30 : { 0, SFX_ITEM_POOLABLE }, // SCITEM_SEARCHDATA - stop using this!
31 : { SID_SORT, SFX_ITEM_POOLABLE }, // SCITEM_SORTDATA
32 : { SID_QUERY, SFX_ITEM_POOLABLE }, // SCITEM_QUERYDATA
33 : { SID_SUBTOTALS, SFX_ITEM_POOLABLE }, // SCITEM_SUBTDATA
34 : { SID_CONSOLIDATE, SFX_ITEM_POOLABLE }, // SCITEM_CONSOLIDATEDATA
35 : { SID_PIVOT_TABLE, SFX_ITEM_POOLABLE }, // SCITEM_PIVOTDATA
36 : { SID_SOLVE, SFX_ITEM_POOLABLE }, // SCITEM_SOLVEDATA
37 : { SID_SCUSERLISTS, SFX_ITEM_POOLABLE }, // SCITEM_USERLIST
38 : { SID_PRINTER_NOTFOUND_WARN, SFX_ITEM_POOLABLE } // SCITEM_PRINTWARN
39 : };
40 :
41 76 : ScMessagePool::ScMessagePool()
42 : : SfxItemPool ( OUString("ScMessagePool"),
43 : MSGPOOL_START, MSGPOOL_END,
44 : aMsgItemInfos, NULL ),
45 :
46 : aGlobalStringItem ( SfxStringItem ( SCITEM_STRING, OUString() ) ),
47 : aGlobalSearchItem ( SvxSearchItem ( SCITEM_SEARCHDATA ) ),
48 : aGlobalSortItem ( ScSortItem ( SCITEM_SORTDATA, NULL ) ),
49 : aGlobalQueryItem ( ScQueryItem ( SCITEM_QUERYDATA, NULL, NULL ) ),
50 : aGlobalSubTotalItem ( ScSubTotalItem ( SCITEM_SUBTDATA, NULL, NULL ) ),
51 : aGlobalConsolidateItem ( ScConsolidateItem ( SCITEM_CONSOLIDATEDATA, NULL ) ),
52 : aGlobalPivotItem ( ScPivotItem ( SCITEM_PIVOTDATA, NULL, NULL, false ) ),
53 : aGlobalSolveItem ( ScSolveItem ( SCITEM_SOLVEDATA, NULL ) ),
54 : aGlobalUserListItem ( ScUserListItem ( SCITEM_USERLIST ) ),
55 :
56 76 : aPrintWarnItem ( SfxBoolItem ( SCITEM_PRINTWARN, false ) )
57 : {
58 76 : ppPoolDefaults = new SfxPoolItem*[MSGPOOL_END - MSGPOOL_START + 1];
59 :
60 76 : ppPoolDefaults[SCITEM_STRING - MSGPOOL_START] = &aGlobalStringItem;
61 76 : ppPoolDefaults[SCITEM_SEARCHDATA - MSGPOOL_START] = &aGlobalSearchItem;
62 76 : ppPoolDefaults[SCITEM_SORTDATA - MSGPOOL_START] = &aGlobalSortItem;
63 76 : ppPoolDefaults[SCITEM_QUERYDATA - MSGPOOL_START] = &aGlobalQueryItem;
64 76 : ppPoolDefaults[SCITEM_SUBTDATA - MSGPOOL_START] = &aGlobalSubTotalItem;
65 76 : ppPoolDefaults[SCITEM_CONSOLIDATEDATA - MSGPOOL_START] = &aGlobalConsolidateItem;
66 76 : ppPoolDefaults[SCITEM_PIVOTDATA - MSGPOOL_START] = &aGlobalPivotItem;
67 76 : ppPoolDefaults[SCITEM_SOLVEDATA - MSGPOOL_START] = &aGlobalSolveItem;
68 76 : ppPoolDefaults[SCITEM_USERLIST - MSGPOOL_START] = &aGlobalUserListItem;
69 76 : ppPoolDefaults[SCITEM_PRINTWARN - MSGPOOL_START] = &aPrintWarnItem;
70 :
71 76 : SetDefaults( ppPoolDefaults );
72 :
73 76 : pDocPool = new ScDocumentPool;
74 :
75 76 : SetSecondaryPool( pDocPool );
76 76 : }
77 :
78 60 : ScMessagePool::~ScMessagePool()
79 : {
80 20 : Delete();
81 20 : SetSecondaryPool( NULL ); // before deleting defaults (accesses defaults)
82 :
83 220 : for ( sal_uInt16 i=0; i <= MSGPOOL_END-MSGPOOL_START; i++ )
84 200 : SetRefCount( *ppPoolDefaults[i], 0 );
85 :
86 20 : delete[] ppPoolDefaults;
87 :
88 20 : SfxItemPool::Free(pDocPool);
89 40 : }
90 :
91 124849 : SfxMapUnit ScMessagePool::GetMetric( sal_uInt16 nWhich ) const
92 : {
93 : // Own attributes: Twips, everything else 1/100 mm
94 124849 : if ( nWhich >= ATTR_STARTINDEX && nWhich <= ATTR_ENDINDEX )
95 1940 : return SFX_MAPUNIT_TWIP;
96 : else
97 122909 : return SFX_MAPUNIT_100TH_MM;
98 228 : }
99 :
100 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|