tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / reportdesign / source / core / api / ReportComponent.cxx
blobadfee3596914b43cb5a516939f9266ef7956ab6b
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 <comphelper/solarmutex.hxx>
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/i18n/ScriptType.hpp>
31 #include <comphelper/uno3.hxx>
32 #include <unotools/lingucfg.hxx>
33 #include <i18nlangtag/mslangid.hxx>
34 #include <i18nlangtag/languagetag.hxx>
37 namespace reportdesign
40 using namespace com::sun::star;
41 using namespace comphelper;
43 static void lcl_getDefaultFonts( vcl::Font& rLatinFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont, LanguageType _eLatin, LanguageType _eCJK, LanguageType _eCTL )
45 SolarMutexGuard g;
46 LanguageType eLatin = _eLatin;
48 // If the UI language is Korean, the default Latin font has to
49 // be queried for Korean, too (the Latin language from the document can't be Korean).
50 // This is the same logic as in SwDocShell::InitNew.
51 LanguageType eUiLanguage = Application::GetSettings().GetUILanguageTag().getLanguageType();
52 if (MsLangId::isKorean(eUiLanguage))
53 eLatin = eUiLanguage;
55 rLatinFont = OutputDevice::GetDefaultFont( DefaultFontType::LATIN_PRESENTATION, eLatin, GetDefaultFontFlags::OnlyOne );
56 rCJKFont = OutputDevice::GetDefaultFont( DefaultFontType::CJK_PRESENTATION, _eCJK, GetDefaultFontFlags::OnlyOne );
57 rCTLFont = OutputDevice::GetDefaultFont( DefaultFontType::CTL_PRESENTATION, _eCTL, GetDefaultFontFlags::OnlyOne ) ;
59 OFormatProperties::OFormatProperties()
60 :nAlign(style::ParagraphAdjust_LEFT)
61 ,nFontEmphasisMark(0)
62 ,nFontRelief(0)
63 ,nTextColor(0)
64 ,nTextLineColor(0)
65 ,nBackgroundColor(COL_TRANSPARENT)
66 ,aVerticalAlignment( style::VerticalAlignment_TOP )
67 ,nCharEscapement(0)
68 ,nCharCaseMap(0)
69 ,nCharKerning(0)
70 ,nCharEscapementHeight(100)
71 ,m_bBackgroundTransparent(true)
72 ,bCharFlash(false)
73 ,bCharAutoKerning(false)
74 ,bCharCombineIsOn(false)
75 ,bCharHidden(false)
76 ,bCharShadowed(false)
77 ,bCharContoured(false)
79 try
81 SvtLinguConfig aLinguConfig;
82 using namespace ::com::sun::star::i18n::ScriptType;
84 aLinguConfig.GetProperty(u"DefaultLocale") >>= aCharLocale;
85 LanguageType eCurLang = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aCharLocale, false), LATIN);
86 aLinguConfig.GetProperty(u"DefaultLocale_CJK") >>= aCharLocaleAsian;
87 LanguageType eCurLangCJK = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aCharLocaleAsian, false), ASIAN);
88 aLinguConfig.GetProperty(u"DefaultLocale_CTL") >>= aCharLocaleComplex;
89 LanguageType eCurLangCTL = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aCharLocaleComplex, false), COMPLEX);
91 vcl::Font aLatin,aCJK,aCTL;
92 lcl_getDefaultFonts(aLatin,aCJK,aCTL,eCurLang,eCurLangCJK,eCurLangCTL);
93 aFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aLatin);
94 aAsianFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aCJK);
95 aComplexFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aCTL);
97 catch(const uno::Exception&)
100 aFontDescriptor.Weight = awt::FontWeight::NORMAL;
101 aFontDescriptor.CharacterWidth = awt::FontWidth::NORMAL;
104 void OReportComponentProperties::setShape(uno::Reference< drawing::XShape >& _xShape,const uno::Reference< report::XReportComponent>& _xTunnel,oslInterlockedCount& _rRefCount)
106 osl_atomic_increment( &_rRefCount );
108 m_xProxy.set(_xShape,uno::UNO_QUERY);
109 ::comphelper::query_aggregation(m_xProxy,m_xShape);
110 ::comphelper::query_aggregation(m_xProxy,m_xProperty);
111 _xShape.clear();
112 m_xTypeProvider.set(m_xShape,uno::UNO_QUERY);
113 m_xUnoTunnel.set(m_xShape,uno::UNO_QUERY);
114 m_xServiceInfo.set(m_xShape,uno::UNO_QUERY);
116 // set ourself as delegator
117 if ( m_xProxy.is() )
118 m_xProxy->setDelegator( _xTunnel );
120 osl_atomic_decrement( &_rRefCount );
123 OReportComponentProperties::~OReportComponentProperties()
125 if ( m_xProxy.is() )
127 m_xProxy->setDelegator( nullptr );
128 m_xProxy.clear();
132 } // namespace reportdesign
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */