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 #include "ReportComponent.hxx"
24
25 #ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC
26 #include "corestrings.hrc"
27 #endif
28 #include <vcl/svapp.hxx>
29 #include <vcl/outdev.hxx>
30 #include <toolkit/helper/vclunohelper.hxx>
31 #include <tools/debug.hxx>
32 #include <com/sun/star/awt/FontWeight.hpp>
33 #include <com/sun/star/awt/FontWidth.hpp>
34 #include "ReportControlModel.hxx"
35 #include <com/sun/star/reflection/XProxyFactory.hpp>
36 #include <com/sun/star/text/ParagraphVertAlign.hpp>
37 #include <com/sun/star/style/ParagraphAdjust.hpp>
38 #include <com/sun/star/i18n/ScriptType.hpp>
39 #include <editeng/unolingu.hxx>
40 #include <unotools/syslocale.hxx>
41 #include <unotools/lingucfg.hxx>
42 #include <i18npool/mslangid.hxx>
43
44 // =============================================================================
45 namespace reportdesign
46 {
47 // =============================================================================
48 using namespace com::sun::star;
49 using namespace comphelper;
50
lcl_getDefaultFonts(Font & rLatinFont,Font & rCJKFont,Font & rCTLFont,LanguageType _eLatin,LanguageType _eCJK,LanguageType _eCTL)51 void lcl_getDefaultFonts( Font& rLatinFont, Font& rCJKFont, Font& rCTLFont,LanguageType _eLatin,LanguageType _eCJK,LanguageType _eCTL )
52 {
53 LanguageType eLatin = _eLatin;
54
55 // #108374# / #107782#: If the UI language is Korean, the default Latin font has to
56 // be queried for Korean, too (the Latin language from the document can't be Korean).
57 // This is the same logic as in SwDocShell::InitNew.
58 LanguageType eUiLanguage = Application::GetSettings().GetUILanguage();
59 switch( eUiLanguage )
60 {
61 case LANGUAGE_KOREAN:
62 case LANGUAGE_KOREAN_JOHAB:
63 eLatin = eUiLanguage;
64 break;
65 }
66
67 rLatinFont = OutputDevice::GetDefaultFont( DEFAULTFONT_LATIN_PRESENTATION, eLatin, DEFAULTFONT_FLAGS_ONLYONE );
68 rCJKFont = OutputDevice::GetDefaultFont( DEFAULTFONT_CJK_PRESENTATION, _eCJK, DEFAULTFONT_FLAGS_ONLYONE );
69 rCTLFont = OutputDevice::GetDefaultFont( DEFAULTFONT_CTL_PRESENTATION, _eCTL, DEFAULTFONT_FLAGS_ONLYONE ) ;
70 }
OFormatProperties()71 OFormatProperties::OFormatProperties()
72 :nAlign(style::ParagraphAdjust_LEFT)
73 ,nFontEmphasisMark(0)
74 ,nFontRelief(0)
75 ,nTextColor(0)
76 ,nTextLineColor(0)
77 ,nCharUnderlineColor(0xFFFFFFFF)
78 ,nBackgroundColor(COL_TRANSPARENT)
79 ,aVerticalAlignment( style::VerticalAlignment_TOP )
80 ,nCharEscapement(0)
81 ,nCharCaseMap(0)
82 ,nCharKerning(0)
83 ,nCharEscapementHeight(100)
84 ,m_bBackgroundTransparent(sal_True)
85 ,bCharFlash(sal_False)
86 ,bCharAutoKerning(sal_False)
87 ,bCharCombineIsOn(sal_False)
88 ,bCharHidden(sal_False)
89 ,bCharShadowed(sal_False)
90 ,bCharContoured(sal_False)
91 {
92 try
93 {
94 SvtLinguConfig aLinguConfig;
95 using namespace ::com::sun::star::i18n::ScriptType;
96
97 aLinguConfig.GetProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultLocale"))) >>= aCharLocale;
98 LanguageType eCurLang = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aCharLocale), LATIN);
99 aLinguConfig.GetProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultLocale_CJK"))) >>= aCharLocaleAsian;
100 LanguageType eCurLangCJK = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aCharLocaleAsian), ASIAN);
101 aLinguConfig.GetProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultLocale_CTL"))) >>= aCharLocaleComplex;
102 LanguageType eCurLangCTL = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aCharLocaleComplex), COMPLEX);
103
104 Font aLatin,aCJK,aCTL;
105 lcl_getDefaultFonts(aLatin,aCJK,aCTL,eCurLang,eCurLangCJK,eCurLangCTL);
106 aFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aLatin);
107 aAsianFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aCJK);
108 aComplexFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aCTL);
109 }
110 catch(const uno::Exception&)
111 {
112 }
113 aFontDescriptor.Weight = awt::FontWeight::NORMAL;
114 aFontDescriptor.CharacterWidth = awt::FontWidth::NORMAL;
115 // aCharLocale = SvtSysLocale().GetLocaleData().getLocale();
116 }
117 // -----------------------------------------------------------------------------
setShape(uno::Reference<drawing::XShape> & _xShape,const uno::Reference<report::XReportComponent> & _xTunnel,oslInterlockedCount & _rRefCount)118 void OReportComponentProperties::setShape(uno::Reference< drawing::XShape >& _xShape,const uno::Reference< report::XReportComponent>& _xTunnel,oslInterlockedCount& _rRefCount)
119 {
120 osl_incrementInterlockedCount( &_rRefCount );
121 {
122 m_xProxy.set(_xShape,uno::UNO_QUERY);
123 ::comphelper::query_aggregation(m_xProxy,m_xShape);
124 ::comphelper::query_aggregation(m_xProxy,m_xProperty);
125 _xShape.clear();
126 m_xTypeProvider.set(m_xShape,uno::UNO_QUERY);
127 m_xUnoTunnel.set(m_xShape,uno::UNO_QUERY);
128 m_xServiceInfo.set(m_xShape,uno::UNO_QUERY);
129
130 // set ourself as delegator
131 if ( m_xProxy.is() )
132 m_xProxy->setDelegator( _xTunnel );
133 }
134 osl_decrementInterlockedCount( &_rRefCount );
135 }
136 // -----------------------------------------------------------------------------
~OReportComponentProperties()137 OReportComponentProperties::~OReportComponentProperties()
138 {
139 if ( m_xProxy.is() )
140 {
141 m_xProxy->setDelegator( NULL );
142 m_xProxy.clear();
143 }
144 }
145 // =============================================================================
146 } // namespace reportdesign
147 // =============================================================================
148
149
150