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