bump product version to 5.0.4.1
[LibreOffice.git] / reportdesign / source / core / api / ReportComponent.cxx
blob9bc9fd2ee0f95c6d570f0741b90e07a35d41ea82
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include "ReportComponent.hxx"
21 #include "corestrings.hrc"
22 #include <vcl/svapp.hxx>
23 #include <vcl/outdev.hxx>
24 #include <vcl/settings.hxx>
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>
41 namespace reportdesign
44 using namespace com::sun::star;
45 using namespace comphelper;
47 void lcl_getDefaultFonts( vcl::Font& rLatinFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont, LanguageType _eLatin, LanguageType _eCJK, LanguageType _eCTL )
49 LanguageType eLatin = _eLatin;
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 LanguageType eUiLanguage = Application::GetSettings().GetUILanguageTag().getLanguageType();
55 if (MsLangId::isKorean(eUiLanguage))
56 eLatin = eUiLanguage;
58 rLatinFont = OutputDevice::GetDefaultFont( DefaultFontType::LATIN_PRESENTATION, eLatin, GetDefaultFontFlags::OnlyOne );
59 rCJKFont = OutputDevice::GetDefaultFont( DefaultFontType::CJK_PRESENTATION, _eCJK, GetDefaultFontFlags::OnlyOne );
60 rCTLFont = OutputDevice::GetDefaultFont( DefaultFontType::CTL_PRESENTATION, _eCTL, GetDefaultFontFlags::OnlyOne ) ;
62 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(true)
76 ,bCharFlash(false)
77 ,bCharAutoKerning(false)
78 ,bCharCombineIsOn(false)
79 ,bCharHidden(false)
80 ,bCharShadowed(false)
81 ,bCharContoured(false)
83 try
85 SvtLinguConfig aLinguConfig;
86 using namespace ::com::sun::star::i18n::ScriptType;
88 aLinguConfig.GetProperty(OUString("DefaultLocale")) >>= aCharLocale;
89 LanguageType eCurLang = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aCharLocale, false), LATIN);
90 aLinguConfig.GetProperty(OUString("DefaultLocale_CJK")) >>= aCharLocaleAsian;
91 LanguageType eCurLangCJK = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aCharLocaleAsian, false), ASIAN);
92 aLinguConfig.GetProperty(OUString("DefaultLocale_CTL")) >>= aCharLocaleComplex;
93 LanguageType eCurLangCTL = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aCharLocaleComplex, false), COMPLEX);
95 vcl::Font aLatin,aCJK,aCTL;
96 lcl_getDefaultFonts(aLatin,aCJK,aCTL,eCurLang,eCurLangCJK,eCurLangCTL);
97 aFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aLatin);
98 aAsianFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aCJK);
99 aComplexFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aCTL);
101 catch(const uno::Exception&)
104 aFontDescriptor.Weight = awt::FontWeight::NORMAL;
105 aFontDescriptor.CharacterWidth = awt::FontWidth::NORMAL;
108 void OReportComponentProperties::setShape(uno::Reference< drawing::XShape >& _xShape,const uno::Reference< report::XReportComponent>& _xTunnel,oslInterlockedCount& _rRefCount)
110 osl_atomic_increment( &_rRefCount );
112 m_xProxy.set(_xShape,uno::UNO_QUERY);
113 ::comphelper::query_aggregation(m_xProxy,m_xShape);
114 ::comphelper::query_aggregation(m_xProxy,m_xProperty);
115 _xShape.clear();
116 m_xTypeProvider.set(m_xShape,uno::UNO_QUERY);
117 m_xUnoTunnel.set(m_xShape,uno::UNO_QUERY);
118 m_xServiceInfo.set(m_xShape,uno::UNO_QUERY);
120 // set ourself as delegator
121 if ( m_xProxy.is() )
122 m_xProxy->setDelegator( _xTunnel );
124 osl_atomic_decrement( &_rRefCount );
127 OReportComponentProperties::~OReportComponentProperties()
129 if ( m_xProxy.is() )
131 m_xProxy->setDelegator( NULL );
132 m_xProxy.clear();
136 } // namespace reportdesign
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */