LibreOffice Module reportdesign (master)  1
ReportComponent.cxx
Go to the documentation of this file.
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 <vcl/svapp.hxx>
22 #include <vcl/outdev.hxx>
23 #include <vcl/settings.hxx>
24 
26 #include <com/sun/star/awt/FontWeight.hpp>
27 #include <com/sun/star/awt/FontWidth.hpp>
28 #include <ReportControlModel.hxx>
29 #include <com/sun/star/i18n/ScriptType.hpp>
30 #include <comphelper/uno3.hxx>
31 #include <unotools/lingucfg.hxx>
32 #include <i18nlangtag/mslangid.hxx>
34 
35 
36 namespace reportdesign
37 {
38 
39  using namespace com::sun::star;
40  using namespace comphelper;
41 
42 static void lcl_getDefaultFonts( vcl::Font& rLatinFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont, LanguageType _eLatin, LanguageType _eCJK, LanguageType _eCTL )
43 {
44  LanguageType eLatin = _eLatin;
45 
46  // If the UI language is Korean, the default Latin font has to
47  // be queried for Korean, too (the Latin language from the document can't be Korean).
48  // This is the same logic as in SwDocShell::InitNew.
50  if (MsLangId::isKorean(eUiLanguage))
51  eLatin = eUiLanguage;
52 
53  rLatinFont = OutputDevice::GetDefaultFont( DefaultFontType::LATIN_PRESENTATION, eLatin, GetDefaultFontFlags::OnlyOne );
54  rCJKFont = OutputDevice::GetDefaultFont( DefaultFontType::CJK_PRESENTATION, _eCJK, GetDefaultFontFlags::OnlyOne );
55  rCTLFont = OutputDevice::GetDefaultFont( DefaultFontType::CTL_PRESENTATION, _eCTL, GetDefaultFontFlags::OnlyOne ) ;
56 }
58  :nAlign(style::ParagraphAdjust_LEFT)
59  ,nFontEmphasisMark(0)
60  ,nFontRelief(0)
61  ,nTextColor(0)
62  ,nTextLineColor(0)
63  ,nBackgroundColor(COL_TRANSPARENT)
64  ,aVerticalAlignment( style::VerticalAlignment_TOP )
65  ,nCharEscapement(0)
66  ,nCharCaseMap(0)
67  ,nCharKerning(0)
68  ,nCharEscapementHeight(100)
69  ,m_bBackgroundTransparent(true)
70  ,bCharFlash(false)
71  ,bCharAutoKerning(false)
72  ,bCharCombineIsOn(false)
73  ,bCharHidden(false)
74  ,bCharShadowed(false)
75  ,bCharContoured(false)
76 {
77  try
78  {
79  SvtLinguConfig aLinguConfig;
80  using namespace ::com::sun::star::i18n::ScriptType;
81 
82  aLinguConfig.GetProperty("DefaultLocale") >>= aCharLocale;
84  aLinguConfig.GetProperty("DefaultLocale_CJK") >>= aCharLocaleAsian;
86  aLinguConfig.GetProperty("DefaultLocale_CTL") >>= aCharLocaleComplex;
88 
89  vcl::Font aLatin,aCJK,aCTL;
90  lcl_getDefaultFonts(aLatin,aCJK,aCTL,eCurLang,eCurLangCJK,eCurLangCTL);
94  }
95  catch(const uno::Exception&)
96  {
97  }
98  aFontDescriptor.Weight = awt::FontWeight::NORMAL;
99  aFontDescriptor.CharacterWidth = awt::FontWidth::NORMAL;
100 }
101 
102 void OReportComponentProperties::setShape(uno::Reference< drawing::XShape >& _xShape,const uno::Reference< report::XReportComponent>& _xTunnel,oslInterlockedCount& _rRefCount)
103 {
104  osl_atomic_increment( &_rRefCount );
105  {
106  m_xProxy.set(_xShape,uno::UNO_QUERY);
107  ::comphelper::query_aggregation(m_xProxy,m_xShape);
108  ::comphelper::query_aggregation(m_xProxy,m_xProperty);
109  _xShape.clear();
110  m_xTypeProvider.set(m_xShape,uno::UNO_QUERY);
111  m_xUnoTunnel.set(m_xShape,uno::UNO_QUERY);
112  m_xServiceInfo.set(m_xShape,uno::UNO_QUERY);
113 
114  // set ourself as delegator
115  if ( m_xProxy.is() )
116  m_xProxy->setDelegator( _xTunnel );
117  }
118  osl_atomic_decrement( &_rRefCount );
119 }
120 
122 {
123  if ( m_xProxy.is() )
124  {
125  m_xProxy->setDelegator( nullptr );
126  m_xProxy.clear();
127  }
128 }
129 
130 } // namespace reportdesign
131 
132 
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
css::awt::FontDescriptor aComplexFontDescriptor
static void lcl_getDefaultFonts(vcl::Font &rLatinFont, vcl::Font &rCJKFont, vcl::Font &rCTLFont, LanguageType _eLatin, LanguageType _eCJK, LanguageType _eCTL)
const LanguageTag & GetUILanguageTag() const
LanguageType getLanguageType(bool bResolveSystem=true) const
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
static const AllSettings & GetSettings()
static LanguageType resolveSystemLanguageByScriptType(LanguageType nLang, sal_Int16 nType)
#define ASIAN
Definition: UITools.cxx:165
css::uno::Reference< css::lang::XServiceInfo > m_xServiceInfo
void setShape(css::uno::Reference< css::drawing::XShape > &xShape, const css::uno::Reference< css::report::XReportComponent > &xTunnel, oslInterlockedCount &rRefCount)
css::uno::Reference< css::beans::XPropertySet > m_xProperty
exports com.sun.star. style
css::awt::FontDescriptor aAsianFontDescriptor
css::uno::Reference< css::drawing::XShape > m_xShape
css::awt::FontDescriptor aFontDescriptor
css::uno::Reference< css::lang::XTypeProvider > m_xTypeProvider
css::uno::Reference< css::lang::XUnoTunnel > m_xUnoTunnel
static bool isKorean(LanguageType nLang)
css::uno::Any GetProperty(const OUString &rPropertyName) const
css::uno::Reference< css::uno::XAggregation > m_xProxy
static css::awt::FontDescriptor CreateFontDescriptor(const vcl::Font &rFont)
#define COMPLEX
Definition: UITools.cxx:166