1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <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 <i18nlangtag/mslangid.hxx>
36 #include <i18nlangtag/languagetag.hxx>
38 // =============================================================================
39 namespace reportdesign
41 // =============================================================================
42 using namespace com::sun::star
;
43 using namespace comphelper
;
45 void lcl_getDefaultFonts( Font
& rLatinFont
, Font
& rCJKFont
, Font
& rCTLFont
,LanguageType _eLatin
,LanguageType _eCJK
,LanguageType _eCTL
)
47 LanguageType eLatin
= _eLatin
;
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 LanguageType eUiLanguage
= Application::GetSettings().GetUILanguageTag().getLanguageType();
53 if (MsLangId::isKorean(eUiLanguage
))
56 rLatinFont
= OutputDevice::GetDefaultFont( DEFAULTFONT_LATIN_PRESENTATION
, eLatin
, DEFAULTFONT_FLAGS_ONLYONE
);
57 rCJKFont
= OutputDevice::GetDefaultFont( DEFAULTFONT_CJK_PRESENTATION
, _eCJK
, DEFAULTFONT_FLAGS_ONLYONE
);
58 rCTLFont
= OutputDevice::GetDefaultFont( DEFAULTFONT_CTL_PRESENTATION
, _eCTL
, DEFAULTFONT_FLAGS_ONLYONE
) ;
60 OFormatProperties::OFormatProperties()
61 :nAlign(style::ParagraphAdjust_LEFT
)
66 ,nCharUnderlineColor(0xFFFFFFFF)
67 ,nBackgroundColor(COL_TRANSPARENT
)
68 ,aVerticalAlignment( style::VerticalAlignment_TOP
)
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 ,bCharContoured(sal_False
)
83 SvtLinguConfig aLinguConfig
;
84 using namespace ::com::sun::star::i18n::ScriptType
;
86 aLinguConfig
.GetProperty(OUString("DefaultLocale")) >>= aCharLocale
;
87 LanguageType eCurLang
= MsLangId::resolveSystemLanguageByScriptType(LanguageTag(aCharLocale
).getLanguageType(false), LATIN
);
88 aLinguConfig
.GetProperty(OUString("DefaultLocale_CJK")) >>= aCharLocaleAsian
;
89 LanguageType eCurLangCJK
= MsLangId::resolveSystemLanguageByScriptType(LanguageTag(aCharLocaleAsian
).getLanguageType(false), ASIAN
);
90 aLinguConfig
.GetProperty(OUString("DefaultLocale_CTL")) >>= aCharLocaleComplex
;
91 LanguageType eCurLangCTL
= MsLangId::resolveSystemLanguageByScriptType(LanguageTag(aCharLocaleComplex
).getLanguageType(false), COMPLEX
);
93 Font aLatin
,aCJK
,aCTL
;
94 lcl_getDefaultFonts(aLatin
,aCJK
,aCTL
,eCurLang
,eCurLangCJK
,eCurLangCTL
);
95 aFontDescriptor
= VCLUnoHelper::CreateFontDescriptor(aLatin
);
96 aAsianFontDescriptor
= VCLUnoHelper::CreateFontDescriptor(aCJK
);
97 aComplexFontDescriptor
= VCLUnoHelper::CreateFontDescriptor(aCTL
);
99 catch(const uno::Exception
&)
102 aFontDescriptor
.Weight
= awt::FontWeight::NORMAL
;
103 aFontDescriptor
.CharacterWidth
= awt::FontWidth::NORMAL
;
105 // -----------------------------------------------------------------------------
106 void OReportComponentProperties::setShape(uno::Reference
< drawing::XShape
>& _xShape
,const uno::Reference
< report::XReportComponent
>& _xTunnel
,oslInterlockedCount
& _rRefCount
)
108 osl_atomic_increment( &_rRefCount
);
110 m_xProxy
.set(_xShape
,uno::UNO_QUERY
);
111 ::comphelper::query_aggregation(m_xProxy
,m_xShape
);
112 ::comphelper::query_aggregation(m_xProxy
,m_xProperty
);
114 m_xTypeProvider
.set(m_xShape
,uno::UNO_QUERY
);
115 m_xUnoTunnel
.set(m_xShape
,uno::UNO_QUERY
);
116 m_xServiceInfo
.set(m_xShape
,uno::UNO_QUERY
);
118 // set ourself as delegator
120 m_xProxy
->setDelegator( _xTunnel
);
122 osl_atomic_decrement( &_rRefCount
);
124 // -----------------------------------------------------------------------------
125 OReportComponentProperties::~OReportComponentProperties()
129 m_xProxy
->setDelegator( NULL
);
133 // =============================================================================
134 } // namespace reportdesign
135 // =============================================================================
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */