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