lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / reportdesign / source / core / api / ReportComponent.cxx
blob189123e76ad0c6a75373ec4ae6e49323e1ed4c02
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 <strings.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/reflection/XProxyFactory.hpp>
31 #include <com/sun/star/text/ParagraphVertAlign.hpp>
32 #include <com/sun/star/i18n/ScriptType.hpp>
33 #include <comphelper/uno3.hxx>
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 static 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 ,nBackgroundColor(COL_TRANSPARENT)
69 ,aVerticalAlignment( style::VerticalAlignment_TOP )
70 ,nCharEscapement(0)
71 ,nCharCaseMap(0)
72 ,nCharKerning(0)
73 ,nCharEscapementHeight(100)
74 ,m_bBackgroundTransparent(true)
75 ,bCharFlash(false)
76 ,bCharAutoKerning(false)
77 ,bCharCombineIsOn(false)
78 ,bCharHidden(false)
79 ,bCharShadowed(false)
80 ,bCharContoured(false)
82 try
84 SvtLinguConfig aLinguConfig;
85 using namespace ::com::sun::star::i18n::ScriptType;
87 aLinguConfig.GetProperty(OUString("DefaultLocale")) >>= aCharLocale;
88 LanguageType eCurLang = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aCharLocale, false), LATIN);
89 aLinguConfig.GetProperty(OUString("DefaultLocale_CJK")) >>= aCharLocaleAsian;
90 LanguageType eCurLangCJK = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aCharLocaleAsian, false), ASIAN);
91 aLinguConfig.GetProperty(OUString("DefaultLocale_CTL")) >>= aCharLocaleComplex;
92 LanguageType eCurLangCTL = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aCharLocaleComplex, false), COMPLEX);
94 vcl::Font aLatin,aCJK,aCTL;
95 lcl_getDefaultFonts(aLatin,aCJK,aCTL,eCurLang,eCurLangCJK,eCurLangCTL);
96 aFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aLatin);
97 aAsianFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aCJK);
98 aComplexFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aCTL);
100 catch(const uno::Exception&)
103 aFontDescriptor.Weight = awt::FontWeight::NORMAL;
104 aFontDescriptor.CharacterWidth = awt::FontWidth::NORMAL;
107 void OReportComponentProperties::setShape(uno::Reference< drawing::XShape >& _xShape,const uno::Reference< report::XReportComponent>& _xTunnel,oslInterlockedCount& _rRefCount)
109 osl_atomic_increment( &_rRefCount );
111 m_xProxy.set(_xShape,uno::UNO_QUERY);
112 ::comphelper::query_aggregation(m_xProxy,m_xShape);
113 ::comphelper::query_aggregation(m_xProxy,m_xProperty);
114 _xShape.clear();
115 m_xTypeProvider.set(m_xShape,uno::UNO_QUERY);
116 m_xUnoTunnel.set(m_xShape,uno::UNO_QUERY);
117 m_xServiceInfo.set(m_xShape,uno::UNO_QUERY);
119 // set ourself as delegator
120 if ( m_xProxy.is() )
121 m_xProxy->setDelegator( _xTunnel );
123 osl_atomic_decrement( &_rRefCount );
126 OReportComponentProperties::~OReportComponentProperties()
128 if ( m_xProxy.is() )
130 m_xProxy->setDelegator( nullptr );
131 m_xProxy.clear();
135 } // namespace reportdesign
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */