xref: /trunk/main/sc/source/ui/app/msgpool.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 
32 
33 #include "scitems.hxx"
34 #include <svx/dialogs.hrc>
35 
36 #include "sc.hrc"
37 #include "docpool.hxx"
38 #include "msgpool.hxx"
39 
40 //------------------------------------------------------------------------
41 
42 static SfxItemInfo __READONLY_DATA aMsgItemInfos[] =
43 {
44 	{ 0,						 SFX_ITEM_POOLABLE },	// SCITEM_STRING
45 	{ 0,						 SFX_ITEM_POOLABLE },	// SCITEM_SEARCHDATA - nicht mehr benutzt !!!
46 	{ SID_SORT,					 SFX_ITEM_POOLABLE },	// SCITEM_SORTDATA
47 	{ SID_QUERY,				 SFX_ITEM_POOLABLE },	// SCITEM_QUERYDATA
48 	{ SID_SUBTOTALS,			 SFX_ITEM_POOLABLE },	// SCITEM_SUBTDATA
49 	{ SID_CONSOLIDATE,			 SFX_ITEM_POOLABLE },	// SCITEM_CONSOLIDATEDATA
50 	{ SID_PIVOT_TABLE,			 SFX_ITEM_POOLABLE },	// SCITEM_PIVOTDATA
51 	{ SID_SOLVE,				 SFX_ITEM_POOLABLE },	// SCITEM_SOLVEDATA
52 	{ SID_SCUSERLISTS,			 SFX_ITEM_POOLABLE },	// SCITEM_USERLIST
53 	{ SID_PRINTER_NOTFOUND_WARN, SFX_ITEM_POOLABLE }	// SCITEM_PRINTWARN
54 };
55 
56 //------------------------------------------------------------------------
57 
58 ScMessagePool::ScMessagePool()
59 	:	SfxItemPool         ( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScMessagePool")),
60 							  MSGPOOL_START, MSGPOOL_END,
61 							  aMsgItemInfos, NULL ),
62 	//
63 	aGlobalStringItem   	( SfxStringItem			( SCITEM_STRING, String() ) ),
64 	aGlobalSearchItem   	( SvxSearchItem			( SCITEM_SEARCHDATA ) ),
65 	aGlobalSortItem     	( ScSortItem			( SCITEM_SORTDATA, NULL ) ),
66 	aGlobalQueryItem		( ScQueryItem			( SCITEM_QUERYDATA, NULL, NULL ) ),
67 	aGlobalSubTotalItem		( ScSubTotalItem		( SCITEM_SUBTDATA, NULL, NULL ) ),
68 	aGlobalConsolidateItem	( ScConsolidateItem		( SCITEM_CONSOLIDATEDATA, NULL ) ),
69 	aGlobalPivotItem		( ScPivotItem			( SCITEM_PIVOTDATA, NULL, NULL, sal_False ) ),
70 	aGlobalSolveItem		( ScSolveItem			( SCITEM_SOLVEDATA, NULL ) ),
71 	aGlobalUserListItem		( ScUserListItem		( SCITEM_USERLIST ) ),
72 	//
73 	aPrintWarnItem      	( SfxBoolItem			( SCITEM_PRINTWARN, sal_False ) )
74 {
75 	ppPoolDefaults = new SfxPoolItem*[MSGPOOL_END - MSGPOOL_START + 1];
76 
77 	ppPoolDefaults[SCITEM_STRING			- MSGPOOL_START] = &aGlobalStringItem;
78 	ppPoolDefaults[SCITEM_SEARCHDATA		- MSGPOOL_START] = &aGlobalSearchItem;
79 	ppPoolDefaults[SCITEM_SORTDATA			- MSGPOOL_START] = &aGlobalSortItem;
80 	ppPoolDefaults[SCITEM_QUERYDATA			- MSGPOOL_START] = &aGlobalQueryItem;
81 	ppPoolDefaults[SCITEM_SUBTDATA			- MSGPOOL_START] = &aGlobalSubTotalItem;
82 	ppPoolDefaults[SCITEM_CONSOLIDATEDATA	- MSGPOOL_START] = &aGlobalConsolidateItem;
83 	ppPoolDefaults[SCITEM_PIVOTDATA			- MSGPOOL_START] = &aGlobalPivotItem;
84 	ppPoolDefaults[SCITEM_SOLVEDATA			- MSGPOOL_START] = &aGlobalSolveItem;
85 	ppPoolDefaults[SCITEM_USERLIST			- MSGPOOL_START] = &aGlobalUserListItem;
86 	ppPoolDefaults[SCITEM_PRINTWARN			- MSGPOOL_START] = &aPrintWarnItem;
87 
88 	SetDefaults( ppPoolDefaults );
89 
90 	pDocPool = new ScDocumentPool;
91 
92 	SetSecondaryPool( pDocPool );
93 }
94 
95 
96 __EXPORT ScMessagePool::~ScMessagePool()
97 {
98 	Delete();
99 	SetSecondaryPool( NULL );		// before deleting defaults (accesses defaults)
100 
101 	for ( sal_uInt16 i=0; i <= MSGPOOL_END-MSGPOOL_START; i++ )
102 		SetRefCount( *ppPoolDefaults[i], 0 );
103 
104 	delete[] ppPoolDefaults;
105 
106 	SfxItemPool::Free(pDocPool);
107 }
108 
109 
110 SfxMapUnit __EXPORT ScMessagePool::GetMetric( sal_uInt16 nWhich ) const
111 {
112 	//	eigene Attribute: Twips, alles andere 1/100 mm
113 
114 	if ( nWhich >= ATTR_STARTINDEX && nWhich <= ATTR_ENDINDEX )
115 		return SFX_MAPUNIT_TWIP;
116 	else
117 		return SFX_MAPUNIT_100TH_MM;
118 }
119 
120 
121 
122 
123 
124