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