sync master with lastest vba changes
[ooovba.git] / reportdesign / source / core / api / ReportComponent.cxx
blob660800f5e5aaa31d762ff42d7775967b508e3d46
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ReportComponent.cxx,v $
10 * $Revision: 1.4 $
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"
34 #endif
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 <svx/unoshape.hxx>
45 #include <svx/unolingu.hxx>
46 #include <svtools/syslocale.hxx>
47 #include <svtools/lingucfg.hxx>
48 // =============================================================================
49 namespace reportdesign
51 // =============================================================================
52 using namespace com::sun::star;
53 using namespace comphelper;
55 void lcl_getDefaultFonts( Font& rLatinFont, Font& rCJKFont, Font& rCTLFont,LanguageType _eLatin,LanguageType _eCJK,LanguageType _eCTL )
57 LanguageType eLatin = _eLatin;
59 // #108374# / #107782#: If the UI language is Korean, the default Latin font has to
60 // be queried for Korean, too (the Latin language from the document can't be Korean).
61 // This is the same logic as in SwDocShell::InitNew.
62 LanguageType eUiLanguage = Application::GetSettings().GetUILanguage();
63 switch( eUiLanguage )
65 case LANGUAGE_KOREAN:
66 case LANGUAGE_KOREAN_JOHAB:
67 eLatin = eUiLanguage;
68 break;
71 rLatinFont = OutputDevice::GetDefaultFont( DEFAULTFONT_LATIN_PRESENTATION, eLatin, DEFAULTFONT_FLAGS_ONLYONE );
72 rCJKFont = OutputDevice::GetDefaultFont( DEFAULTFONT_CJK_PRESENTATION, _eCJK, DEFAULTFONT_FLAGS_ONLYONE );
73 rCTLFont = OutputDevice::GetDefaultFont( DEFAULTFONT_CTL_PRESENTATION, _eCTL, DEFAULTFONT_FLAGS_ONLYONE ) ;
75 OFormatProperties::OFormatProperties()
76 :nAlign(0)
77 ,nFontEmphasisMark(0)
78 ,nFontRelief(0)
79 ,nTextColor(0)
80 ,nTextLineColor(0)
81 ,nCharUnderlineColor(0xFFFFFFFF)
82 ,nBackgroundColor(COL_TRANSPARENT)
83 ,aVerticalAlignment(text::ParagraphVertAlign::TOP)
84 ,nCharEscapement(0)
85 ,nCharCaseMap(0)
86 ,nCharKerning(0)
87 ,nCharEscapementHeight(100)
88 ,m_bBackgroundTransparent(sal_True)
89 ,bCharFlash(sal_False)
90 ,bCharAutoKerning(sal_False)
91 ,bCharCombineIsOn(sal_False)
92 ,bCharHidden(sal_False)
93 ,bCharShadowed(sal_False)
94 ,bCharContoured(sal_False)
96 try
98 SvtLinguConfig aLinguConfig;
99 aLinguConfig.GetProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultLocale"))) >>= aCharLocale;
100 LanguageType eCurLang = SvxLocaleToLanguage( aCharLocale );
101 aLinguConfig.GetProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultLocale_CJK"))) >>= aCharLocaleAsian;
102 LanguageType eCurLangCJK = SvxLocaleToLanguage( aCharLocaleAsian );
103 aLinguConfig.GetProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultLocale_CTL"))) >>= aCharLocaleComplex;
104 LanguageType eCurLangCTL = SvxLocaleToLanguage( aCharLocaleComplex );
106 Font aLatin,aCJK,aCTL;
107 lcl_getDefaultFonts(aLatin,aCJK,aCTL,eCurLang,eCurLangCJK,eCurLangCTL);
108 aFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aLatin);
109 aAsianFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aCJK);
110 aComplexFontDescriptor = VCLUnoHelper::CreateFontDescriptor(aCTL);
112 catch(const uno::Exception&)
115 aFontDescriptor.Weight = awt::FontWeight::NORMAL;
116 aFontDescriptor.CharacterWidth = awt::FontWidth::NORMAL;
118 // aCharLocale = SvtSysLocale().GetLocaleData().getLocale();
120 // -----------------------------------------------------------------------------
121 void OReportComponentProperties::setShape(uno::Reference< drawing::XShape >& _xShape,const uno::Reference< report::XReportComponent>& _xTunnel,oslInterlockedCount& _rRefCount)
123 osl_incrementInterlockedCount( &_rRefCount );
125 m_xProxy.set(_xShape,uno::UNO_QUERY);
126 ::comphelper::query_aggregation(m_xProxy,m_xShape);
127 ::comphelper::query_aggregation(m_xProxy,m_xProperty);
128 _xShape.clear();
129 m_xTypeProvider.set(m_xShape,uno::UNO_QUERY);
130 m_xUnoTunnel.set(m_xShape,uno::UNO_QUERY);
131 m_xServiceInfo.set(m_xShape,uno::UNO_QUERY);
133 // set ourself as delegator
134 if ( m_xProxy.is() )
135 m_xProxy->setDelegator( _xTunnel );
137 osl_decrementInterlockedCount( &_rRefCount );
139 // -----------------------------------------------------------------------------
140 OReportComponentProperties::~OReportComponentProperties()
142 if ( m_xProxy.is() )
144 m_xProxy->setDelegator( NULL );
145 m_xProxy.clear();
148 // =============================================================================
149 } // namespace reportdesign
150 // =============================================================================