1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ReportComponent.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "ReportComponent.hxx"
32 #ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC
33 #include "corestrings.hrc"
35 #include <vcl/svapp.hxx>
36 #include <vcl/outdev.hxx>
37 #include <toolkit/helper/vclunohelper.hxx>
38 #include <tools/debug.hxx>
39 #include <com/sun/star/awt/FontWeight.hpp>
40 #include <com/sun/star/awt/FontWidth.hpp>
41 #include "ReportControlModel.hxx"
42 #include <com/sun/star/reflection/XProxyFactory.hpp>
43 #include <com/sun/star/text/ParagraphVertAlign.hpp>
44 #include <com/sun/star/style/ParagraphAdjust.hpp>
45 #include <com/sun/star/i18n/ScriptType.hpp>
46 #include <svx/unolingu.hxx>
47 #include <svtools/syslocale.hxx>
48 #include <svtools/lingucfg.hxx>
49 #include <i18npool/mslangid.hxx>
51 // =============================================================================
52 namespace reportdesign
54 // =============================================================================
55 using namespace com::sun::star
;
56 using namespace comphelper
;
58 void lcl_getDefaultFonts( Font
& rLatinFont
, Font
& rCJKFont
, Font
& rCTLFont
,LanguageType _eLatin
,LanguageType _eCJK
,LanguageType _eCTL
)
60 LanguageType eLatin
= _eLatin
;
62 // #108374# / #107782#: If the UI language is Korean, the default Latin font has to
63 // be queried for Korean, too (the Latin language from the document can't be Korean).
64 // This is the same logic as in SwDocShell::InitNew.
65 LanguageType eUiLanguage
= Application::GetSettings().GetUILanguage();
69 case LANGUAGE_KOREAN_JOHAB
:
74 rLatinFont
= OutputDevice::GetDefaultFont( DEFAULTFONT_LATIN_PRESENTATION
, eLatin
, DEFAULTFONT_FLAGS_ONLYONE
);
75 rCJKFont
= OutputDevice::GetDefaultFont( DEFAULTFONT_CJK_PRESENTATION
, _eCJK
, DEFAULTFONT_FLAGS_ONLYONE
);
76 rCTLFont
= OutputDevice::GetDefaultFont( DEFAULTFONT_CTL_PRESENTATION
, _eCTL
, DEFAULTFONT_FLAGS_ONLYONE
) ;
78 OFormatProperties::OFormatProperties()
79 :nAlign(style::ParagraphAdjust_LEFT
)
84 ,nCharUnderlineColor(0xFFFFFFFF)
85 ,nBackgroundColor(COL_TRANSPARENT
)
86 ,aVerticalAlignment( style::VerticalAlignment_TOP
)
90 ,nCharEscapementHeight(100)
91 ,m_bBackgroundTransparent(sal_True
)
92 ,bCharFlash(sal_False
)
93 ,bCharAutoKerning(sal_False
)
94 ,bCharCombineIsOn(sal_False
)
95 ,bCharHidden(sal_False
)
96 ,bCharShadowed(sal_False
)
97 ,bCharContoured(sal_False
)
101 SvtLinguConfig aLinguConfig
;
102 using namespace ::com::sun::star::i18n::ScriptType
;
104 aLinguConfig
.GetProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultLocale"))) >>= aCharLocale
;
105 LanguageType eCurLang
= MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aCharLocale
), LATIN
);
106 aLinguConfig
.GetProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultLocale_CJK"))) >>= aCharLocaleAsian
;
107 LanguageType eCurLangCJK
= MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aCharLocaleAsian
), ASIAN
);
108 aLinguConfig
.GetProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultLocale_CTL"))) >>= aCharLocaleComplex
;
109 LanguageType eCurLangCTL
= MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aCharLocaleComplex
), COMPLEX
);
111 Font aLatin
,aCJK
,aCTL
;
112 lcl_getDefaultFonts(aLatin
,aCJK
,aCTL
,eCurLang
,eCurLangCJK
,eCurLangCTL
);
113 aFontDescriptor
= VCLUnoHelper::CreateFontDescriptor(aLatin
);
114 aAsianFontDescriptor
= VCLUnoHelper::CreateFontDescriptor(aCJK
);
115 aComplexFontDescriptor
= VCLUnoHelper::CreateFontDescriptor(aCTL
);
117 catch(const uno::Exception
&)
120 aFontDescriptor
.Weight
= awt::FontWeight::NORMAL
;
121 aFontDescriptor
.CharacterWidth
= awt::FontWidth::NORMAL
;
122 // aCharLocale = SvtSysLocale().GetLocaleData().getLocale();
124 // -----------------------------------------------------------------------------
125 void OReportComponentProperties::setShape(uno::Reference
< drawing::XShape
>& _xShape
,const uno::Reference
< report::XReportComponent
>& _xTunnel
,oslInterlockedCount
& _rRefCount
)
127 osl_incrementInterlockedCount( &_rRefCount
);
129 m_xProxy
.set(_xShape
,uno::UNO_QUERY
);
130 ::comphelper::query_aggregation(m_xProxy
,m_xShape
);
131 ::comphelper::query_aggregation(m_xProxy
,m_xProperty
);
133 m_xTypeProvider
.set(m_xShape
,uno::UNO_QUERY
);
134 m_xUnoTunnel
.set(m_xShape
,uno::UNO_QUERY
);
135 m_xServiceInfo
.set(m_xShape
,uno::UNO_QUERY
);
137 // set ourself as delegator
139 m_xProxy
->setDelegator( _xTunnel
);
141 osl_decrementInterlockedCount( &_rRefCount
);
143 // -----------------------------------------------------------------------------
144 OReportComponentProperties::~OReportComponentProperties()
148 m_xProxy
->setDelegator( NULL
);
152 // =============================================================================
153 } // namespace reportdesign
154 // =============================================================================