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 :
21 : #include <vcl/wrkwin.hxx>
22 : #include <vcl/dialog.hxx>
23 : #include <vcl/msgbox.hxx>
24 : #include <vcl/svapp.hxx>
25 : #include <vcl/settings.hxx>
26 : #include <com/sun/star/linguistic2/LanguageGuessing.hpp>
27 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28 : #include <comphelper/processfactory.hxx>
29 :
30 : #include <svl/solar.hrc>
31 : #include <editeng/eerdll.hxx>
32 : #include <eerdll2.hxx>
33 : #include <editeng/lspcitem.hxx>
34 : #include <editeng/adjustitem.hxx>
35 : #include <editeng/tstpitem.hxx>
36 : #include <editeng/bulletitem.hxx>
37 : #include <editeng/flditem.hxx>
38 : #include <editeng/emphasismarkitem.hxx>
39 : #include <editeng/scriptspaceitem.hxx>
40 : #include <editeng/numdef.hxx>
41 : #include <svl/itempool.hxx>
42 : #include <svl/grabbagitem.hxx>
43 : #include <vcl/virdev.hxx>
44 :
45 : #include <editeng/autokernitem.hxx>
46 : #include <editeng/contouritem.hxx>
47 : #include <editeng/colritem.hxx>
48 : #include <editeng/crossedoutitem.hxx>
49 : #include <editeng/charsetcoloritem.hxx>
50 : #include <editeng/escapementitem.hxx>
51 : #include <editeng/fhgtitem.hxx>
52 : #include <editeng/fontitem.hxx>
53 : #include <editeng/kernitem.hxx>
54 : #include <editeng/lrspitem.hxx>
55 : #include <editeng/postitem.hxx>
56 : #include <editeng/shdditem.hxx>
57 : #include <editeng/udlnitem.hxx>
58 : #include <editeng/ulspitem.hxx>
59 : #include <editeng/wghtitem.hxx>
60 : #include <editeng/wrlmitem.hxx>
61 : #include <editeng/numitem.hxx>
62 : #include <editeng/langitem.hxx>
63 : #include <editeng/cmapitem.hxx>
64 : #include <editeng/charscaleitem.hxx>
65 : #include <editeng/charreliefitem.hxx>
66 : #include <editeng/frmdiritem.hxx>
67 : #include <editeng/xmlcnitm.hxx>
68 : #include <editeng/forbiddencharacterstable.hxx>
69 : #include <editeng/justifyitem.hxx>
70 : #include <rtl/instance.hxx>
71 :
72 : using namespace ::com::sun::star;
73 :
74 : namespace
75 : {
76 : class theEditDLL : public rtl::Static<EditDLL, theEditDLL> {};
77 : }
78 :
79 133443 : EditDLL& EditDLL::Get()
80 : {
81 133443 : return theEditDLL::get();
82 : }
83 :
84 115 : GlobalEditData::GlobalEditData()
85 : {
86 115 : ppDefItems = NULL;
87 115 : }
88 :
89 230 : GlobalEditData::~GlobalEditData()
90 : {
91 : // Destroy DefItems...
92 : // Or simply keep them, since at end of execution?!
93 115 : if ( ppDefItems )
94 115 : SfxItemPool::ReleaseDefaults( ppDefItems, EDITITEMCOUNT, true );
95 115 : }
96 :
97 56134 : SfxPoolItem** GlobalEditData::GetDefItems()
98 : {
99 56134 : if ( !ppDefItems )
100 : {
101 115 : ppDefItems = new SfxPoolItem*[EDITITEMCOUNT];
102 :
103 : // Paragraph attributes:
104 230 : SvxNumRule aDefaultNumRule( SvxNumRuleFlags::BULLET_REL_SIZE | SvxNumRuleFlags::BULLET_COLOR | SvxNumRuleFlags::CHAR_TEXT_DISTANCE,
105 115 : SVX_MAX_NUM, false );
106 :
107 115 : ppDefItems[0] = new SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR );
108 115 : ppDefItems[1] = new SvXMLAttrContainerItem( EE_PARA_XMLATTRIBS );
109 115 : ppDefItems[2] = new SfxBoolItem( EE_PARA_HANGINGPUNCTUATION, false );
110 115 : ppDefItems[3] = new SfxBoolItem( EE_PARA_FORBIDDENRULES, true );
111 115 : ppDefItems[4] = new SvxScriptSpaceItem( true, EE_PARA_ASIANCJKSPACING );
112 115 : ppDefItems[5] = new SvxNumBulletItem( aDefaultNumRule, EE_PARA_NUMBULLET );
113 115 : ppDefItems[6] = new SfxBoolItem( EE_PARA_HYPHENATE, false );
114 115 : ppDefItems[7] = new SfxBoolItem( EE_PARA_BULLETSTATE, true );
115 115 : ppDefItems[8] = new SvxLRSpaceItem( EE_PARA_OUTLLRSPACE );
116 115 : ppDefItems[9] = new SfxInt16Item( EE_PARA_OUTLLEVEL, -1 );
117 115 : ppDefItems[10] = new SvxBulletItem( EE_PARA_BULLET );
118 115 : ppDefItems[11] = new SvxLRSpaceItem( EE_PARA_LRSPACE );
119 115 : ppDefItems[12] = new SvxULSpaceItem( EE_PARA_ULSPACE );
120 115 : ppDefItems[13] = new SvxLineSpacingItem( 0, EE_PARA_SBL );
121 115 : ppDefItems[14] = new SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST );
122 115 : ppDefItems[15] = new SvxTabStopItem( 0, 0, SVX_TAB_ADJUST_LEFT, EE_PARA_TABS );
123 115 : ppDefItems[16] = new SvxJustifyMethodItem( SVX_JUSTIFY_METHOD_AUTO, EE_PARA_JUST_METHOD );
124 115 : ppDefItems[17] = new SvxVerJustifyItem( SVX_VER_JUSTIFY_STANDARD, EE_PARA_VER_JUST );
125 :
126 : // Character attributes:
127 115 : ppDefItems[18] = new SvxColorItem( Color( COL_AUTO ), EE_CHAR_COLOR );
128 115 : ppDefItems[19] = new SvxFontItem( EE_CHAR_FONTINFO );
129 115 : ppDefItems[20] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT );
130 115 : ppDefItems[21] = new SvxCharScaleWidthItem( 100, EE_CHAR_FONTWIDTH );
131 115 : ppDefItems[22] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT );
132 115 : ppDefItems[23] = new SvxUnderlineItem( UNDERLINE_NONE, EE_CHAR_UNDERLINE );
133 115 : ppDefItems[24] = new SvxCrossedOutItem( STRIKEOUT_NONE, EE_CHAR_STRIKEOUT );
134 115 : ppDefItems[25] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC );
135 115 : ppDefItems[26] = new SvxContourItem( false, EE_CHAR_OUTLINE );
136 115 : ppDefItems[27] = new SvxShadowedItem( false, EE_CHAR_SHADOW );
137 115 : ppDefItems[28] = new SvxEscapementItem( 0, 100, EE_CHAR_ESCAPEMENT );
138 115 : ppDefItems[29] = new SvxAutoKernItem( false, EE_CHAR_PAIRKERNING );
139 115 : ppDefItems[30] = new SvxKerningItem( 0, EE_CHAR_KERNING );
140 115 : ppDefItems[31] = new SvxWordLineModeItem( false, EE_CHAR_WLM );
141 115 : ppDefItems[32] = new SvxLanguageItem( LANGUAGE_DONTKNOW, EE_CHAR_LANGUAGE );
142 115 : ppDefItems[33] = new SvxLanguageItem( LANGUAGE_DONTKNOW, EE_CHAR_LANGUAGE_CJK );
143 115 : ppDefItems[34] = new SvxLanguageItem( LANGUAGE_DONTKNOW, EE_CHAR_LANGUAGE_CTL );
144 115 : ppDefItems[35] = new SvxFontItem( EE_CHAR_FONTINFO_CJK );
145 115 : ppDefItems[36] = new SvxFontItem( EE_CHAR_FONTINFO_CTL );
146 115 : ppDefItems[37] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT_CJK );
147 115 : ppDefItems[38] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT_CTL );
148 115 : ppDefItems[39] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK );
149 115 : ppDefItems[40] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL );
150 115 : ppDefItems[41] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK );
151 115 : ppDefItems[42] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL );
152 115 : ppDefItems[43] = new SvxEmphasisMarkItem( EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK );
153 115 : ppDefItems[44] = new SvxCharReliefItem( RELIEF_NONE, EE_CHAR_RELIEF );
154 115 : ppDefItems[45] = new SfxVoidItem( EE_CHAR_RUBI_DUMMY );
155 115 : ppDefItems[46] = new SvXMLAttrContainerItem( EE_CHAR_XMLATTRIBS );
156 115 : ppDefItems[47] = new SvxOverlineItem( UNDERLINE_NONE, EE_CHAR_OVERLINE );
157 115 : ppDefItems[48] = new SvxCaseMapItem( SVX_CASEMAP_NOT_MAPPED, EE_CHAR_CASEMAP );
158 115 : ppDefItems[49] = new SfxGrabBagItem( EE_CHAR_GRABBAG );
159 115 : ppDefItems[50] = new SvxBackgroundColorItem( Color( COL_AUTO ), EE_CHAR_BKGCOLOR );
160 : // Features
161 115 : ppDefItems[51] = new SfxVoidItem( EE_FEATURE_TAB );
162 115 : ppDefItems[52] = new SfxVoidItem( EE_FEATURE_LINEBR );
163 115 : ppDefItems[53] = new SvxCharSetColorItem( Color( COL_RED ), RTL_TEXTENCODING_DONTKNOW, EE_FEATURE_NOTCONV );
164 115 : ppDefItems[54] = new SvxFieldItem( SvxFieldData(), EE_FEATURE_FIELD );
165 :
166 : assert(EDITITEMCOUNT == 55 && "ITEMCOUNT changed, adjust DefItems!");
167 :
168 : // Init DefFonts:
169 115 : GetDefaultFonts( *static_cast<SvxFontItem*>(ppDefItems[EE_CHAR_FONTINFO - EE_ITEMS_START]),
170 115 : *static_cast<SvxFontItem*>(ppDefItems[EE_CHAR_FONTINFO_CJK - EE_ITEMS_START]),
171 345 : *static_cast<SvxFontItem*>(ppDefItems[EE_CHAR_FONTINFO_CTL - EE_ITEMS_START]) );
172 : }
173 :
174 56134 : return ppDefItems;
175 : }
176 :
177 8230 : rtl::Reference<SvxForbiddenCharactersTable> GlobalEditData::GetForbiddenCharsTable()
178 : {
179 8230 : if ( !xForbiddenCharsTable.is() )
180 : {
181 2887 : xForbiddenCharsTable = new SvxForbiddenCharactersTable( ::comphelper::getProcessComponentContext() );
182 : }
183 8230 : return xForbiddenCharsTable;
184 : }
185 :
186 0 : uno::Reference< linguistic2::XLanguageGuessing > GlobalEditData::GetLanguageGuesser()
187 : {
188 0 : if (!xLanguageGuesser.is())
189 : {
190 0 : xLanguageGuesser = linguistic2::LanguageGuessing::create( comphelper::getProcessComponentContext() );
191 : }
192 0 : return xLanguageGuesser;
193 : }
194 :
195 260912 : EditResId::EditResId(sal_uInt16 nId)
196 260912 : : ResId(nId, *EditDLL::GetResMgr())
197 : {
198 260912 : }
199 :
200 115 : EditDLL::EditDLL()
201 : {
202 115 : pGlobalData = new GlobalEditData;
203 115 : }
204 :
205 115 : EditDLL::~EditDLL()
206 : {
207 115 : delete pGlobalData;
208 115 : }
209 :
210 : static ResMgr* pResMgr=0;
211 :
212 260912 : ResMgr* EditDLL::GetResMgr()
213 : {
214 260912 : if (!pResMgr)
215 88 : pResMgr = ResMgr::CreateResMgr("editeng", Application::GetSettings().GetUILanguageTag());
216 260912 : return pResMgr;
217 : }
218 :
219 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|