LibreOffice Module editeng (master) 1
eerdll.cxx
Go to the documentation of this file.
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 <unotools/resmgr.hxx>
22#include <com/sun/star/linguistic2/LanguageGuessing.hpp>
23
25
26#include <editeng/eeitem.hxx>
27#include <editeng/eerdll.hxx>
28#include <eerdll2.hxx>
29#include <editeng/lspcitem.hxx>
31#include <editeng/tstpitem.hxx>
33#include <editeng/flditem.hxx>
38#include <svl/grabbagitem.hxx>
39#include <vcl/svapp.hxx>
40#include <vcl/virdev.hxx>
41
44#include <editeng/colritem.hxx>
47#include <editeng/fhgtitem.hxx>
48#include <editeng/fontitem.hxx>
49#include <editeng/kernitem.hxx>
50#include <editeng/lrspitem.hxx>
51#include <editeng/postitem.hxx>
52#include <editeng/shdditem.hxx>
53#include <editeng/udlnitem.hxx>
54#include <editeng/ulspitem.hxx>
55#include <editeng/wghtitem.hxx>
56#include <editeng/wrlmitem.hxx>
57#include <editeng/numitem.hxx>
58#include <editeng/langitem.hxx>
59#include <editeng/cmapitem.hxx>
63#include <editeng/xmlcnitm.hxx>
66#include <tools/mapunit.hxx>
67#include <vcl/lazydelete.hxx>
68
69using namespace ::com::sun::star;
70
72{
78 static vcl::DeleteOnDeinit< EditDLL > gaEditDll;
79 return *gaEditDll.get();
80}
81
83 : mvDefItems(EDITITEMCOUNT)
84{
85 std::vector<SfxPoolItem*>& rDefItems = mvDefItems;
86
87 // Paragraph attributes:
88 SvxNumRule aDefaultNumRule( SvxNumRuleFlags::NONE, 0, false );
89
91 rDefItems[1] = new SvXMLAttrContainerItem( EE_PARA_XMLATTRIBS );
93 rDefItems[3] = new SvxForbiddenRuleItem(true, EE_PARA_FORBIDDENRULES);
94 rDefItems[4] = new SvxScriptSpaceItem( true, EE_PARA_ASIANCJKSPACING );
95 rDefItems[5] = new SvxNumBulletItem( aDefaultNumRule, EE_PARA_NUMBULLET );
96 rDefItems[6] = new SfxBoolItem( EE_PARA_HYPHENATE, false );
97 rDefItems[7] = new SfxBoolItem( EE_PARA_HYPHENATE_NO_CAPS, false );
98 rDefItems[8] = new SfxBoolItem( EE_PARA_HYPHENATE_NO_LAST_WORD, false );
99 rDefItems[9] = new SfxBoolItem( EE_PARA_BULLETSTATE, true );
100 rDefItems[10] = new SvxLRSpaceItem( EE_PARA_OUTLLRSPACE );
101 rDefItems[11] = new SfxInt16Item( EE_PARA_OUTLLEVEL, -1 );
102 rDefItems[12] = new SvxBulletItem( EE_PARA_BULLET );
103 rDefItems[13] = new SvxLRSpaceItem( EE_PARA_LRSPACE );
104 rDefItems[14] = new SvxULSpaceItem( EE_PARA_ULSPACE );
105 rDefItems[15] = new SvxLineSpacingItem( 0, EE_PARA_SBL );
106 rDefItems[16] = new SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST );
107 rDefItems[17] = new SvxTabStopItem( 0, 0, SvxTabAdjust::Left, EE_PARA_TABS );
110
111 // Character attributes:
112 rDefItems[20] = new SvxColorItem( COL_AUTO, EE_CHAR_COLOR );
113 rDefItems[21] = new SvxFontItem( EE_CHAR_FONTINFO );
114 rDefItems[22] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT );
115 rDefItems[23] = new SvxCharScaleWidthItem( 100, EE_CHAR_FONTWIDTH );
116 rDefItems[24] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT );
117 rDefItems[25] = new SvxUnderlineItem( LINESTYLE_NONE, EE_CHAR_UNDERLINE );
118 rDefItems[26] = new SvxCrossedOutItem( STRIKEOUT_NONE, EE_CHAR_STRIKEOUT );
119 rDefItems[27] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC );
120 rDefItems[28] = new SvxContourItem( false, EE_CHAR_OUTLINE );
121 rDefItems[29] = new SvxShadowedItem( false, EE_CHAR_SHADOW );
122 rDefItems[30] = new SvxEscapementItem( 0, 100, EE_CHAR_ESCAPEMENT );
123 rDefItems[31] = new SvxAutoKernItem( false, EE_CHAR_PAIRKERNING );
124 rDefItems[32] = new SvxKerningItem( 0, EE_CHAR_KERNING );
125 rDefItems[33] = new SvxWordLineModeItem( false, EE_CHAR_WLM );
126 rDefItems[34] = new SvxLanguageItem( LANGUAGE_DONTKNOW, EE_CHAR_LANGUAGE );
129 rDefItems[37] = new SvxFontItem( EE_CHAR_FONTINFO_CJK );
130 rDefItems[38] = new SvxFontItem( EE_CHAR_FONTINFO_CTL );
131 rDefItems[39] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT_CJK );
132 rDefItems[40] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT_CTL );
133 rDefItems[41] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK );
134 rDefItems[42] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL );
135 rDefItems[43] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK );
136 rDefItems[44] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL );
137 rDefItems[45] = new SvxEmphasisMarkItem( FontEmphasisMark::NONE, EE_CHAR_EMPHASISMARK );
138 rDefItems[46] = new SvxCharReliefItem( FontRelief::NONE, EE_CHAR_RELIEF );
139 rDefItems[47] = new SfxVoidItem( EE_CHAR_RUBI_DUMMY );
140 rDefItems[48] = new SvXMLAttrContainerItem( EE_CHAR_XMLATTRIBS );
141 rDefItems[49] = new SvxOverlineItem( LINESTYLE_NONE, EE_CHAR_OVERLINE );
143 rDefItems[51] = new SfxGrabBagItem( EE_CHAR_GRABBAG );
144 rDefItems[52] = new SvxColorItem( COL_AUTO, EE_CHAR_BKGCOLOR );
145 // Features
146 rDefItems[53] = new SfxVoidItem( EE_FEATURE_TAB );
147 rDefItems[54] = new SfxVoidItem( EE_FEATURE_LINEBR );
148 rDefItems[55] = new SvxColorItem( COL_RED, EE_FEATURE_NOTCONV );
149 rDefItems[56] = new SvxFieldItem( SvxFieldData(), EE_FEATURE_FIELD );
150
151 assert(EDITITEMCOUNT == 57 && "ITEMCOUNT changed, adjust DefItems!");
152
153 // Init DefFonts:
154 GetDefaultFonts( *static_cast<SvxFontItem*>(rDefItems[EE_CHAR_FONTINFO - EE_ITEMS_START]),
155 *static_cast<SvxFontItem*>(rDefItems[EE_CHAR_FONTINFO_CJK - EE_ITEMS_START]),
156 *static_cast<SvxFontItem*>(rDefItems[EE_CHAR_FONTINFO_CTL - EE_ITEMS_START]) );
157}
158
160{
161 for (const auto& rItem : mvDefItems)
162 delete rItem;
163}
164
165std::shared_ptr<DefItems> GlobalEditData::GetDefItems()
166{
167 auto xDefItems = m_xDefItems.lock();
168 if (!xDefItems)
169 {
170 xDefItems = std::make_shared<DefItems>();
171 m_xDefItems = xDefItems;
172 }
173 return xDefItems;
174}
175
176std::shared_ptr<SvxForbiddenCharactersTable> const & GlobalEditData::GetForbiddenCharsTable()
177{
179 xForbiddenCharsTable = SvxForbiddenCharactersTable::makeForbiddenCharactersTable(::comphelper::getProcessComponentContext());
181}
182
183uno::Reference< linguistic2::XLanguageGuessing > const & GlobalEditData::GetLanguageGuesser()
184{
185 if (!xLanguageGuesser.is())
186 {
187 xLanguageGuesser = linguistic2::LanguageGuessing::create( comphelper::getProcessComponentContext() );
188 }
189 return xLanguageGuesser;
190}
191
193{
194 return Translate::get(aId, Translate::Create("editeng"));
195}
196
198 : pGlobalData( new GlobalEditData )
199{
200}
201
203{
204}
205
207 : m_pVirDev(VclPtr<VirtualDevice>::Create())
208{
209 m_pVirDev->SetMapMode(MapMode(MapUnit::MapTwip));
210}
211
213 { m_pVirDev.disposeAndClear(); }
214
216 { return m_pVirDev; }
217
218std::shared_ptr<editeng::SharedVclResources> EditDLL::GetSharedVclResources()
219{
221 auto pLocked(pSharedVcl.lock());
222 if(!pLocked)
223 pSharedVcl = pLocked = std::make_shared<editeng::SharedVclResources>();
224 return pLocked;
225}
226
227/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DefItems()
Definition: eerdll.cxx:82
~DefItems()
Definition: eerdll.cxx:159
std::vector< SfxPoolItem * > mvDefItems
Definition: eerdll2.hxx:49
std::shared_ptr< editeng::SharedVclResources > GetSharedVclResources()
Definition: eerdll.cxx:218
~EditDLL()
Definition: eerdll.cxx:202
static EditDLL & Get()
Definition: eerdll.cxx:71
EditDLL()
Definition: eerdll.cxx:197
std::shared_ptr< SvxForbiddenCharactersTable > const & GetForbiddenCharsTable()
Definition: eerdll.cxx:176
std::shared_ptr< SvxForbiddenCharactersTable > xForbiddenCharsTable
Definition: eerdll2.hxx:57
css::uno::Reference< css::linguistic2::XLanguageGuessing > const & GetLanguageGuesser()
Definition: eerdll.cxx:183
css::uno::Reference< css::linguistic2::XLanguageGuessing > xLanguageGuesser
Definition: eerdll2.hxx:55
std::weak_ptr< DefItems > m_xDefItems
Definition: eerdll2.hxx:56
std::shared_ptr< DefItems > GetDefItems()
Definition: eerdll.cxx:165
SvxColorItem item describes a color.
Definition: colritem.hxx:32
This item stores a field (SvxFieldData).
Definition: flditem.hxx:70
This item describes a Font.
Definition: fontitem.hxx:30
static std::shared_ptr< SvxForbiddenCharactersTable > makeForbiddenCharactersTable(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
VclPtr< VirtualDevice > m_pVirDev
Definition: eerdll2.hxx:34
VclPtr< VirtualDevice > const & GetVirtualDevice() const
Definition: eerdll.cxx:215
constexpr ::Color COL_RED(0x80, 0x00, 0x00)
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr TypedWhichId< SfxVoidItem > EE_CHAR_RUBI_DUMMY(EE_CHAR_START+27)
constexpr TypedWhichId< SvxContourItem > EE_CHAR_OUTLINE(EE_CHAR_START+8)
constexpr TypedWhichId< SfxBoolItem > EE_PARA_HYPHENATE(EE_PARA_START+6)
constexpr TypedWhichId< SvxVerJustifyItem > EE_PARA_VER_JUST(EE_PARA_START+19)
constexpr TypedWhichId< SvxHangingPunctuationItem > EE_PARA_HANGINGPUNCTUATION(EE_PARA_START+2)
constexpr TypedWhichId< SvxKerningItem > EE_CHAR_KERNING(EE_CHAR_START+12)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CJK(EE_CHAR_START+17)
constexpr TypedWhichId< SvxFieldItem > EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
constexpr TypedWhichId< SfxBoolItem > EE_PARA_BULLETSTATE(EE_PARA_START+9)
constexpr TypedWhichId< SvxTabStopItem > EE_PARA_TABS(EE_PARA_START+17)
constexpr sal_uInt16 EDITITEMCOUNT(EE_ITEMS_END - EE_ITEMS_START+1)
constexpr TypedWhichId< SvxUnderlineItem > EE_CHAR_UNDERLINE(EE_CHAR_START+5)
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+16)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
constexpr TypedWhichId< SfxBoolItem > EE_PARA_HYPHENATE_NO_CAPS(EE_PARA_START+7)
constexpr TypedWhichId< SvxAutoKernItem > EE_CHAR_PAIRKERNING(EE_CHAR_START+11)
constexpr TypedWhichId< SvxShadowedItem > EE_CHAR_SHADOW(EE_CHAR_START+9)
constexpr TypedWhichId< SfxBoolItem > EE_PARA_HYPHENATE_NO_LAST_WORD(EE_PARA_START+8)
constexpr TypedWhichId< SvxULSpaceItem > EE_PARA_ULSPACE(EE_PARA_START+14)
constexpr TypedWhichId< SvxOverlineItem > EE_CHAR_OVERLINE(EE_CHAR_START+29)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CTL(EE_CHAR_START+16)
constexpr sal_uInt16 EE_FEATURE_LINEBR(EE_FEATURE_TAB+1)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
constexpr TypedWhichId< SvxLRSpaceItem > EE_PARA_LRSPACE(EE_PARA_START+13)
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CTL(EE_CHAR_START+22)
constexpr TypedWhichId< SvXMLAttrContainerItem > EE_PARA_XMLATTRIBS(EE_PARA_START+1)
constexpr TypedWhichId< SvxCrossedOutItem > EE_CHAR_STRIKEOUT(EE_CHAR_START+6)
constexpr TypedWhichId< SvxForbiddenRuleItem > EE_PARA_FORBIDDENRULES(EE_PARA_START+3)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC(EE_CHAR_START+7)
constexpr TypedWhichId< SfxGrabBagItem > EE_CHAR_GRABBAG(EE_CHAR_START+31)
constexpr sal_uInt16 EE_FEATURE_NOTCONV(EE_FEATURE_LINEBR+1)
constexpr TypedWhichId< SvxLineSpacingItem > EE_PARA_SBL(EE_PARA_START+15)
constexpr TypedWhichId< SvxEmphasisMarkItem > EE_CHAR_EMPHASISMARK(EE_CHAR_START+25)
constexpr TypedWhichId< SvxEscapementItem > EE_CHAR_ESCAPEMENT(EE_CHAR_START+10)
constexpr TypedWhichId< SvxBulletItem > EE_PARA_BULLET(EE_PARA_START+12)
constexpr TypedWhichId< SfxInt16Item > EE_PARA_OUTLLEVEL(EE_PARA_START+11)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CJK(EE_CHAR_START+21)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CJK(EE_CHAR_START+15)
constexpr TypedWhichId< SvxFrameDirectionItem > EE_PARA_WRITINGDIR(EE_PARA_START+0)
constexpr sal_uInt16 EE_FEATURE_TAB(EE_FEATURE_START+0)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC_CJK(EE_CHAR_START+23)
constexpr TypedWhichId< SvxCaseMapItem > EE_CHAR_CASEMAP(EE_CHAR_START+30)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CTL(EE_CHAR_START+18)
constexpr TypedWhichId< SvxColorItem > EE_CHAR_BKGCOLOR(EE_CHAR_START+32)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC_CTL(EE_CHAR_START+24)
constexpr TypedWhichId< SvxCharScaleWidthItem > EE_CHAR_FONTWIDTH(EE_CHAR_START+3)
constexpr TypedWhichId< SvxLRSpaceItem > EE_PARA_OUTLLRSPACE(EE_PARA_START+10)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE(EE_CHAR_START+14)
constexpr TypedWhichId< SvXMLAttrContainerItem > EE_CHAR_XMLATTRIBS(EE_CHAR_START+28)
constexpr TypedWhichId< SvxScriptSpaceItem > EE_PARA_ASIANCJKSPACING(EE_PARA_START+4)
constexpr TypedWhichId< SvxNumBulletItem > EE_PARA_NUMBULLET(EE_PARA_START+5)
constexpr sal_uInt16 EE_ITEMS_START(OWN_ATTR_VALUE_END+1)
constexpr TypedWhichId< SvxWordLineModeItem > EE_CHAR_WLM(EE_CHAR_START+13)
constexpr TypedWhichId< SvxJustifyMethodItem > EE_PARA_JUST_METHOD(EE_PARA_START+18)
constexpr TypedWhichId< SvxCharReliefItem > EE_CHAR_RELIEF(EE_CHAR_START+26)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
OUString EditResId(TranslateId aId)
Definition: eerdll.cxx:192
LINESTYLE_NONE
STRIKEOUT_NONE
ITALIC_NONE
WEIGHT_NORMAL
@ Horizontal_LR_TB
Horizontal, from left to right, from top to bottom (typical for western languages).
#define LANGUAGE_DONTKNOW
std::locale Create(std::string_view aPrefixName, const LanguageTag &rLocale)
OUString get(TranslateId sContextAndId, const std::locale &loc)
Reference< XComponentContext > getProcessComponentContext()
void Create(SvxFontItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:65
void GetDefaultFonts(SvxFontItem &rLatin, SvxFontItem &rAsian, SvxFontItem &rComplex)
Definition: textitem.cxx:2774