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 <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();
66 case LANGUAGE_KOREAN_JOHAB
:
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()
81 ,nCharUnderlineColor(0xFFFFFFFF)
82 ,nBackgroundColor(COL_TRANSPARENT
)
83 ,aVerticalAlignment(text::ParagraphVertAlign::TOP
)
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
)
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
);
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
135 m_xProxy
->setDelegator( _xTunnel
);
137 osl_decrementInterlockedCount( &_rRefCount
);
139 // -----------------------------------------------------------------------------
140 OReportComponentProperties::~OReportComponentProperties()
144 m_xProxy
->setDelegator( NULL
);
148 // =============================================================================
149 } // namespace reportdesign
150 // =============================================================================