merge the formfield patch from ooo-build
[ooovba.git] / svx / source / editeng / eerdll.cxx
blobce23a1e00e932ea7d77d19208bea96a606000318
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: eerdll.cxx,v $
10 * $Revision: 1.31.148.1 $
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_svx.hxx"
34 #include <eeng_pch.hxx>
35 #include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 #include <comphelper/processfactory.hxx>
39 #include <svtools/solar.hrc>
40 #include <eerdll.hxx>
41 #include <eerdll2.hxx>
42 #include <svx/lspcitem.hxx>
43 #include <svx/adjitem.hxx>
44 #include <svx/tstpitem.hxx>
45 #include <bulitem.hxx>
46 #include <svx/flditem.hxx>
47 #include <svx/emphitem.hxx>
48 #include <svx/scriptspaceitem.hxx>
49 #include <svtools/itempool.hxx>
50 #include <vcl/virdev.hxx>
51 #include <vcl/svapp.hxx>
53 #include <svx/akrnitem.hxx>
54 #include <svx/cntritem.hxx>
55 #include <svx/colritem.hxx>
56 #include <svx/crsditem.hxx>
57 #include <svx/cscoitem.hxx>
58 #include <svx/escpitem.hxx>
59 #include <svx/fhgtitem.hxx>
60 #include <fontitem.hxx>
61 #include <svx/kernitem.hxx>
62 #include <svx/lrspitem.hxx>
63 #include <svx/postitem.hxx>
64 #include <svx/shdditem.hxx>
65 #include <svx/udlnitem.hxx>
66 #include <svx/ulspitem.hxx>
67 #include <svx/wghtitem.hxx>
68 #include <svx/wrlmitem.hxx>
69 #include <svx/numitem.hxx>
70 #include <svx/langitem.hxx>
71 #include <svx/charscaleitem.hxx>
72 #include <svx/charreliefitem.hxx>
73 #include <svx/frmdiritem.hxx>
74 #include <xmlcnitm.hxx>
76 #include <forbiddencharacterstable.hxx>
78 #include <comphelper/processfactory.hxx>
80 static EditDLL* pDLL=0;
82 using namespace ::com::sun::star;
84 EditDLL* EditDLL::Get()
86 if ( !pDLL )
87 pDLL = new EditDLL;
88 return pDLL;
91 GlobalEditData::GlobalEditData()
93 ppDefItems = NULL;
94 pStdRefDevice = NULL;
97 GlobalEditData::~GlobalEditData()
99 // DefItems zerstoeren...
100 // Oder einfach stehen lassen, da sowieso App-Ende?!
101 if ( ppDefItems )
102 SfxItemPool::ReleaseDefaults( ppDefItems, EDITITEMCOUNT, TRUE );
103 delete pStdRefDevice;
106 SfxPoolItem** GlobalEditData::GetDefItems()
108 if ( !ppDefItems )
110 ppDefItems = new SfxPoolItem*[EDITITEMCOUNT];
112 // Absatzattribute:
113 SvxNumRule aTmpNumRule( 0, 0, FALSE );
115 ppDefItems[0] = new SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR );
116 ppDefItems[1] = new SvXMLAttrContainerItem( EE_PARA_XMLATTRIBS );
117 ppDefItems[2] = new SfxBoolItem( EE_PARA_HANGINGPUNCTUATION, FALSE );
118 ppDefItems[3] = new SfxBoolItem( EE_PARA_FORBIDDENRULES, TRUE );
119 ppDefItems[4] = new SvxScriptSpaceItem( TRUE, EE_PARA_ASIANCJKSPACING );
120 ppDefItems[5] = new SvxNumBulletItem( aTmpNumRule, EE_PARA_NUMBULLET );
121 ppDefItems[6] = new SfxBoolItem( EE_PARA_HYPHENATE, FALSE );
122 ppDefItems[7] = new SfxBoolItem( EE_PARA_BULLETSTATE, TRUE );
123 ppDefItems[8] = new SvxLRSpaceItem( EE_PARA_OUTLLRSPACE );
124 ppDefItems[9] = new SfxInt16Item( EE_PARA_OUTLLEVEL, -1 );
125 ppDefItems[10] = new SvxBulletItem( EE_PARA_BULLET );
126 ppDefItems[11] = new SvxLRSpaceItem( EE_PARA_LRSPACE );
127 ppDefItems[12] = new SvxULSpaceItem( EE_PARA_ULSPACE );
128 ppDefItems[13] = new SvxLineSpacingItem( 0, EE_PARA_SBL );
129 ppDefItems[14] = new SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST );
130 ppDefItems[15] = new SvxTabStopItem( 0, 0, SVX_TAB_ADJUST_LEFT, EE_PARA_TABS );
132 // Zeichenattribute:
133 ppDefItems[16] = new SvxColorItem( Color( COL_AUTO ), EE_CHAR_COLOR );
134 ppDefItems[17] = new SvxFontItem( EE_CHAR_FONTINFO );
135 ppDefItems[18] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT );
136 ppDefItems[19] = new SvxCharScaleWidthItem( 100, EE_CHAR_FONTWIDTH );
137 ppDefItems[20] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT );
138 ppDefItems[21] = new SvxUnderlineItem( UNDERLINE_NONE, EE_CHAR_UNDERLINE );
139 ppDefItems[22] = new SvxCrossedOutItem( STRIKEOUT_NONE, EE_CHAR_STRIKEOUT );
140 ppDefItems[23] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC );
141 ppDefItems[24] = new SvxContourItem( FALSE, EE_CHAR_OUTLINE );
142 ppDefItems[25] = new SvxShadowedItem( FALSE, EE_CHAR_SHADOW );
143 ppDefItems[26] = new SvxEscapementItem( 0, 100, EE_CHAR_ESCAPEMENT );
144 ppDefItems[27] = new SvxAutoKernItem( FALSE, EE_CHAR_PAIRKERNING );
145 ppDefItems[28] = new SvxKerningItem( 0, EE_CHAR_KERNING );
146 ppDefItems[29] = new SvxWordLineModeItem( FALSE, EE_CHAR_WLM );
147 ppDefItems[30] = new SvxLanguageItem( LANGUAGE_DONTKNOW, EE_CHAR_LANGUAGE );
148 ppDefItems[31] = new SvxLanguageItem( LANGUAGE_DONTKNOW, EE_CHAR_LANGUAGE_CJK );
149 ppDefItems[32] = new SvxLanguageItem( LANGUAGE_DONTKNOW, EE_CHAR_LANGUAGE_CTL );
150 ppDefItems[33] = new SvxFontItem( EE_CHAR_FONTINFO_CJK );
151 ppDefItems[34] = new SvxFontItem( EE_CHAR_FONTINFO_CTL );
152 ppDefItems[35] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT_CJK );
153 ppDefItems[36] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT_CTL );
154 ppDefItems[37] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK );
155 ppDefItems[38] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL );
156 ppDefItems[39] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK );
157 ppDefItems[40] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL );
158 ppDefItems[41] = new SvxEmphasisMarkItem( EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK );
159 ppDefItems[42] = new SvxCharReliefItem( RELIEF_NONE, EE_CHAR_RELIEF );
160 ppDefItems[43] = new SfxVoidItem( EE_CHAR_RUBI_DUMMY );
161 #ifndef SVX_LIGHT
162 ppDefItems[44] = new SvXMLAttrContainerItem( EE_CHAR_XMLATTRIBS );
163 #else
164 // no need to have alien attributes persistent
165 ppDefItems[44] = new SfxVoidItem( EE_CHAR_XMLATTRIBS );
166 #endif // #ifndef SVX_LIGHT
167 ppDefItems[45] = new SvxOverlineItem( UNDERLINE_NONE, EE_CHAR_OVERLINE );
169 // Features
170 ppDefItems[46] = new SfxVoidItem( EE_FEATURE_TAB );
171 ppDefItems[47] = new SfxVoidItem( EE_FEATURE_LINEBR );
172 ppDefItems[48] = new SvxCharSetColorItem( Color( COL_RED ), RTL_TEXTENCODING_DONTKNOW, EE_FEATURE_NOTCONV );
173 ppDefItems[49] = new SvxFieldItem( SvxFieldData(), EE_FEATURE_FIELD );
175 DBG_ASSERT( EDITITEMCOUNT == 50, "ITEMCOUNT geaendert, DefItems nicht angepasst!" );
177 // Init DefFonts:
178 GetDefaultFonts( *(SvxFontItem*)ppDefItems[EE_CHAR_FONTINFO - EE_ITEMS_START],
179 *(SvxFontItem*)ppDefItems[EE_CHAR_FONTINFO_CJK - EE_ITEMS_START],
180 *(SvxFontItem*)ppDefItems[EE_CHAR_FONTINFO_CTL - EE_ITEMS_START] );
183 return ppDefItems;
186 vos::ORef<SvxForbiddenCharactersTable> GlobalEditData::GetForbiddenCharsTable()
188 if ( !xForbiddenCharsTable.isValid() )
190 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
191 xForbiddenCharsTable = new SvxForbiddenCharactersTable( xMSF );
193 return xForbiddenCharsTable;
196 uno::Reference< linguistic2::XLanguageGuessing > GlobalEditData::GetLanguageGuesser()
198 if (!xLanguageGuesser.is())
200 uno::Reference< lang::XMultiServiceFactory > xMgr ( comphelper::getProcessServiceFactory() );
201 if (xMgr.is())
203 xLanguageGuesser = uno::Reference< linguistic2::XLanguageGuessing >(
204 xMgr->createInstance(
205 rtl::OUString::createFromAscii( "com.sun.star.linguistic2.LanguageGuessing" ) ),
206 uno::UNO_QUERY );
209 return xLanguageGuesser;
212 OutputDevice* GlobalEditData::GetStdRefDevice()
214 if ( !pStdRefDevice )
216 pStdRefDevice = new VirtualDevice;
217 pStdRefDevice->SetMapMode( MAP_TWIP );
219 return pStdRefDevice;
222 EditResId::EditResId( USHORT nId ):
223 ResId( nId, *EE_DLL()->GetResMgr() )
227 EditDLL::EditDLL()
229 pGlobalData = new GlobalEditData;
230 ByteString aResMgrName( "svx" );
231 pResMgr = ResMgr::CreateResMgr(
232 aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
235 EditDLL::~EditDLL()
237 delete pResMgr;
238 delete pGlobalData;