xref: /trunk/main/editeng/source/editeng/eerdll.cxx (revision 190118d0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_editeng.hxx"
26 
27 #include <vcl/wrkwin.hxx>
28 #include <vcl/dialog.hxx>
29 #include <vcl/msgbox.hxx>
30 #include <vcl/svapp.hxx>
31 #include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
32 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33 #include <comphelper/processfactory.hxx>
34 
35 #include <svl/solar.hrc>
36 #include <editeng/eerdll.hxx>
37 #include <eerdll2.hxx>
38 #include <editeng/lspcitem.hxx>
39 #include <editeng/adjitem.hxx>
40 #include <editeng/tstpitem.hxx>
41 #include <editeng/bulitem.hxx>
42 #include <editeng/flditem.hxx>
43 #include <editeng/emphitem.hxx>
44 #include <editeng/scriptspaceitem.hxx>
45 #include <svl/itempool.hxx>
46 #include <vcl/virdev.hxx>
47 #include <vcl/svapp.hxx>
48 
49 #include <editeng/akrnitem.hxx>
50 #include <editeng/cntritem.hxx>
51 #include <editeng/colritem.hxx>
52 #include <editeng/crsditem.hxx>
53 #include <editeng/cscoitem.hxx>
54 #include <editeng/escpitem.hxx>
55 #include <editeng/fhgtitem.hxx>
56 #include <editeng/fontitem.hxx>
57 #include <editeng/kernitem.hxx>
58 #include <editeng/lrspitem.hxx>
59 #include <editeng/postitem.hxx>
60 #include <editeng/shdditem.hxx>
61 #include <editeng/udlnitem.hxx>
62 #include <editeng/ulspitem.hxx>
63 #include <editeng/wghtitem.hxx>
64 #include <editeng/wrlmitem.hxx>
65 #include <editeng/numitem.hxx>
66 #include <editeng/langitem.hxx>
67 #include <editeng/charscaleitem.hxx>
68 #include <editeng/charreliefitem.hxx>
69 #include <editeng/frmdiritem.hxx>
70 #include <editeng/xmlcnitm.hxx>
71 #include <editeng/forbiddencharacterstable.hxx>
72 #include <comphelper/processfactory.hxx>
73 
74 static EditDLL* pDLL=0;
75 
76 using namespace ::com::sun::star;
77 
Get()78 EditDLL* EditDLL::Get()
79 {
80 	if ( !pDLL )
81 		pDLL = new EditDLL;
82 	return pDLL;
83 }
84 
GlobalEditData()85 GlobalEditData::GlobalEditData()
86 {
87 	ppDefItems = NULL;
88 	pStdRefDevice = NULL;
89 }
90 
~GlobalEditData()91 GlobalEditData::~GlobalEditData()
92 {
93 	// DefItems zerstoeren...
94 	// Oder einfach stehen lassen, da sowieso App-Ende?!
95 	if ( ppDefItems )
96 		SfxItemPool::ReleaseDefaults( ppDefItems, EDITITEMCOUNT, sal_True );
97 	delete pStdRefDevice;
98 }
99 
GetDefItems()100 SfxPoolItem** GlobalEditData::GetDefItems()
101 {
102 	if ( !ppDefItems )
103 	{
104 		ppDefItems = new SfxPoolItem*[EDITITEMCOUNT];
105 
106 		// Absatzattribute:
107 		SvxNumRule aTmpNumRule( 0, 0, sal_False );
108 
109 		ppDefItems[0]  = new SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR );
110 		ppDefItems[1]  = new SvXMLAttrContainerItem( EE_PARA_XMLATTRIBS );
111 		ppDefItems[2]  = new SfxBoolItem( EE_PARA_HANGINGPUNCTUATION, sal_False );
112 		ppDefItems[3]  = new SfxBoolItem( EE_PARA_FORBIDDENRULES, sal_True );
113 		ppDefItems[4]  = new SvxScriptSpaceItem( sal_True, EE_PARA_ASIANCJKSPACING );
114 		ppDefItems[5]  = new SvxNumBulletItem( aTmpNumRule, EE_PARA_NUMBULLET );
115 		ppDefItems[6]  = new SfxBoolItem( EE_PARA_HYPHENATE, sal_False );
116 		ppDefItems[7]  = new SfxBoolItem( EE_PARA_BULLETSTATE, sal_True );
117 		ppDefItems[8]  = new SvxLRSpaceItem( EE_PARA_OUTLLRSPACE );
118 		ppDefItems[9]  = new SfxInt16Item( EE_PARA_OUTLLEVEL, -1 );
119 		ppDefItems[10]  = new SvxBulletItem( EE_PARA_BULLET );
120 		ppDefItems[11]  = new SvxLRSpaceItem( EE_PARA_LRSPACE );
121 		ppDefItems[12]  = new SvxULSpaceItem( EE_PARA_ULSPACE );
122 		ppDefItems[13]  = new SvxLineSpacingItem( 0, EE_PARA_SBL );
123 		ppDefItems[14]  = new SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST );
124 		ppDefItems[15]  = new SvxTabStopItem( 0, 0, SVX_TAB_ADJUST_LEFT, EE_PARA_TABS );
125 
126 		// Zeichenattribute:
127 		ppDefItems[16]  = new SvxColorItem( Color( COL_AUTO ), EE_CHAR_COLOR );
128 		ppDefItems[17]  = new SvxFontItem( EE_CHAR_FONTINFO );
129 		ppDefItems[18] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT );
130 		ppDefItems[19] = new SvxCharScaleWidthItem( 100, EE_CHAR_FONTWIDTH );
131 		ppDefItems[20] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT );
132 		ppDefItems[21] = new SvxUnderlineItem( UNDERLINE_NONE, EE_CHAR_UNDERLINE );
133 		ppDefItems[22] = new SvxCrossedOutItem( STRIKEOUT_NONE, EE_CHAR_STRIKEOUT );
134 		ppDefItems[23] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC );
135 		ppDefItems[24] = new SvxContourItem( sal_False, EE_CHAR_OUTLINE );
136 		ppDefItems[25] = new SvxShadowedItem( sal_False, EE_CHAR_SHADOW );
137 		ppDefItems[26] = new SvxEscapementItem( 0, 100, EE_CHAR_ESCAPEMENT );
138 		ppDefItems[27] = new SvxAutoKernItem( sal_False, EE_CHAR_PAIRKERNING );
139 		ppDefItems[28] = new SvxKerningItem( 0, EE_CHAR_KERNING );
140 		ppDefItems[29] = new SvxWordLineModeItem( sal_False, EE_CHAR_WLM );
141 		ppDefItems[30] = new SvxLanguageItem( LANGUAGE_DONTKNOW, EE_CHAR_LANGUAGE );
142 		ppDefItems[31] = new SvxLanguageItem( LANGUAGE_DONTKNOW, EE_CHAR_LANGUAGE_CJK );
143 		ppDefItems[32] = new SvxLanguageItem( LANGUAGE_DONTKNOW, EE_CHAR_LANGUAGE_CTL );
144 		ppDefItems[33] = new SvxFontItem( EE_CHAR_FONTINFO_CJK );
145 		ppDefItems[34] = new SvxFontItem( EE_CHAR_FONTINFO_CTL );
146 		ppDefItems[35] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT_CJK );
147 		ppDefItems[36] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT_CTL );
148 		ppDefItems[37] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK );
149  		ppDefItems[38] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL );
150 		ppDefItems[39] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK );
151 		ppDefItems[40] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL );
152 		ppDefItems[41] = new SvxEmphasisMarkItem( EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK );
153 		ppDefItems[42] = new SvxCharReliefItem( RELIEF_NONE, EE_CHAR_RELIEF );
154 		ppDefItems[43] = new SfxVoidItem( EE_CHAR_RUBI_DUMMY );
155 #ifndef SVX_LIGHT
156 		ppDefItems[44] = new SvXMLAttrContainerItem( EE_CHAR_XMLATTRIBS );
157 #else
158         // no need to have alien attributes persistent
159 		ppDefItems[44] = new SfxVoidItem( EE_CHAR_XMLATTRIBS );
160 #endif // #ifndef SVX_LIGHT
161 		ppDefItems[45] = new SvxOverlineItem( UNDERLINE_NONE, EE_CHAR_OVERLINE );
162 
163 		// Features
164 		ppDefItems[46] = new SfxVoidItem( EE_FEATURE_TAB );
165 		ppDefItems[47] = new SfxVoidItem( EE_FEATURE_LINEBR );
166 		ppDefItems[48] = new SvxCharSetColorItem( Color( COL_RED ), RTL_TEXTENCODING_DONTKNOW, EE_FEATURE_NOTCONV );
167 		ppDefItems[49] = new SvxFieldItem( SvxFieldData(), EE_FEATURE_FIELD );
168 
169 		DBG_ASSERT( EDITITEMCOUNT == 50, "ITEMCOUNT geaendert, DefItems nicht angepasst!" );
170 
171 		// Init DefFonts:
172 		GetDefaultFonts( *(SvxFontItem*)ppDefItems[EE_CHAR_FONTINFO - EE_ITEMS_START],
173 						 *(SvxFontItem*)ppDefItems[EE_CHAR_FONTINFO_CJK - EE_ITEMS_START],
174 						 *(SvxFontItem*)ppDefItems[EE_CHAR_FONTINFO_CTL - EE_ITEMS_START] );
175 	}
176 
177 	return ppDefItems;
178 }
179 
GetForbiddenCharsTable()180 vos::ORef<SvxForbiddenCharactersTable> GlobalEditData::GetForbiddenCharsTable()
181 {
182 	if ( !xForbiddenCharsTable.isValid() )
183 	{
184 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
185 		xForbiddenCharsTable = new SvxForbiddenCharactersTable( xMSF );
186 	}
187 	return xForbiddenCharsTable;
188 }
189 
GetLanguageGuesser()190 uno::Reference< linguistic2::XLanguageGuessing > GlobalEditData::GetLanguageGuesser()
191 {
192     if (!xLanguageGuesser.is())
193     {
194         uno::Reference< lang::XMultiServiceFactory > xMgr ( comphelper::getProcessServiceFactory() );
195         if (xMgr.is())
196         {
197             xLanguageGuesser = uno::Reference< linguistic2::XLanguageGuessing >(
198                     xMgr->createInstance(
199                         rtl::OUString::createFromAscii( "com.sun.star.linguistic2.LanguageGuessing" ) ),
200                         uno::UNO_QUERY );
201         }
202     }
203     return xLanguageGuesser;
204 }
205 
GetStdRefDevice()206 OutputDevice* GlobalEditData::GetStdRefDevice()
207 {
208 	if ( !pStdRefDevice )
209 	{
210 		pStdRefDevice = new VirtualDevice;
211 		pStdRefDevice->SetMapMode( MAP_TWIP );
212 	}
213 	return pStdRefDevice;
214 }
215 
EditResId(sal_uInt16 nId)216 EditResId::EditResId( sal_uInt16 nId ):
217 	ResId( nId, *EE_DLL()->GetResMgr() )
218 {
219 }
220 
EditDLL()221 EditDLL::EditDLL()
222 {
223 	pGlobalData = new GlobalEditData;
224 	ByteString aResMgrName( "editeng" );
225 	pResMgr = ResMgr::CreateResMgr(
226         aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
227 }
228 
~EditDLL()229 EditDLL::~EditDLL()
230 {
231 	delete pResMgr;
232 	delete pGlobalData;
233 }
234