24#include <com/sun/star/form/FormComponentType.hpp>
25#include <com/sun/star/awt/VisualEffect.hpp>
26#include <com/sun/star/i18n/ScriptType.hpp>
27#include <com/sun/star/lang/Locale.hpp>
28#include <com/sun/star/awt/FontDescriptor.hpp>
29#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
30#include <com/sun/star/lang/XServiceInfo.hpp>
31#include <com/sun/star/container/XChild.hpp>
50 using namespace ::
utl;
51 using ::com::sun::star::uno::Reference;
52 using ::com::sun::star::uno::XInterface;
53 using ::com::sun::star::uno::UNO_QUERY;
54 using ::com::sun::star::uno::UNO_QUERY_THROW;
55 using ::com::sun::star::uno::UNO_SET_THROW;
56 using ::com::sun::star::uno::Exception;
57 using ::com::sun::star::uno::RuntimeException;
58 using ::com::sun::star::uno::Any;
60 using ::com::sun::star::beans::XPropertySetInfo;
61 using ::com::sun::star::lang::Locale;
62 using ::com::sun::star::awt::FontDescriptor;
63 using ::com::sun::star::style::XStyleFamiliesSupplier;
64 using ::com::sun::star::lang::XServiceInfo;
65 using ::com::sun::star::container::XNameAccess;
66 using ::com::sun::star::container::XChild;
68 namespace FormComponentType = ::com::sun::star::form::FormComponentType;
69 namespace VisualEffect = ::com::sun::star::awt::VisualEffect;
70 namespace ScriptType = ::com::sun::star::i18n::ScriptType;
77 OUString sConfigName =
"/org.openoffice.Office.Common/Forms/ControlLayout/" +
79 return OConfigurationTreeRoot::createWithComponentContext(
80 ::comphelper::getProcessComponentContext(),
84 template<
class INTERFACE_TYPE >
85 Reference< INTERFACE_TYPE > getTypedModelNode(
const Reference< XInterface >& _rxModelNode )
87 Reference< INTERFACE_TYPE > xTypedNode( _rxModelNode, UNO_QUERY );
88 if ( xTypedNode.is() )
92 Reference< XChild > xChild( _rxModelNode, UNO_QUERY );
94 return getTypedModelNode< INTERFACE_TYPE >( xChild->getParent() );
101 bool lcl_getDocumentDefaultStyleAndFamily(
const Reference< XInterface >& _rxDocument, OUString& _rFamilyName, OUString& _rStyleName )
103 bool bSuccess =
true;
104 Reference< XServiceInfo > xDocumentSI( _rxDocument, UNO_QUERY );
105 if ( xDocumentSI.is() )
107 if ( xDocumentSI->supportsService(
"com.sun.star.text.TextDocument")
108 || xDocumentSI->supportsService(
"com.sun.star.text.WebDocument")
111 _rFamilyName =
"ParagraphStyles";
112 _rStyleName =
"Standard";
114 else if ( xDocumentSI->supportsService(
"com.sun.star.sheet.SpreadsheetDocument") )
116 _rFamilyName =
"CellStyles";
117 _rStyleName =
"Default";
119 else if ( xDocumentSI->supportsService(
"com.sun.star.drawing.DrawingDocument")
120 || xDocumentSI->supportsService(
"com.sun.star.presentation.PresentationDocument")
123 _rFamilyName =
"graphics";
124 _rStyleName =
"standard";
133 void lcl_initializeControlFont(
const Reference< XPropertySet >& _rxModel )
138 Reference< XPropertySetInfo > xStylePSI( xStyle->getPropertySetInfo(), UNO_SET_THROW );
147 const char* pCharLocalePropertyName =
"CharLocale";
148 switch ( eSysLocaleScriptType )
150 case ScriptType::LATIN:
153 case ScriptType::ASIAN:
154 pCharLocalePropertyName =
"CharLocaleAsian";
156 case ScriptType::COMPLEX:
157 pCharLocalePropertyName =
"CharLocaleComplex";
160 OSL_FAIL(
"lcl_initializeControlFont: unexpected script type for system locale!" );
164 OUString sCharLocalePropertyName = OUString::createFromAscii( pCharLocalePropertyName );
165 Locale aDocumentCharLocale;
166 if ( xStylePSI->hasPropertyByName( sCharLocalePropertyName ) )
168 OSL_VERIFY( xStyle->getPropertyValue( sCharLocalePropertyName ) >>= aDocumentCharLocale );
171 if ( aDocumentCharLocale.Language.isEmpty() )
173 sCharLocalePropertyName =
"CharLocale";
174 if ( xStylePSI->hasPropertyByName( sCharLocalePropertyName ) )
176 OSL_VERIFY( xStyle->getPropertyValue( sCharLocalePropertyName ) >>= aDocumentCharLocale );
180 if ( aDocumentCharLocale.Language.isEmpty() )
188 _rxModel->setPropertyValue(
"FontDescriptor",
Any( aFontDesc )
191 catch(
const Exception& )
205 Reference< XStyleFamiliesSupplier > xSuppStyleFamilies( getTypedModelNode< XStyleFamiliesSupplier >( _rxModel ), UNO_SET_THROW );
206 Reference< XNameAccess > xStyleFamilies( xSuppStyleFamilies->getStyleFamilies(), UNO_SET_THROW );
209 OUString sFamilyName, sStyleName;
210 if ( !lcl_getDocumentDefaultStyleAndFamily( xSuppStyleFamilies, sFamilyName, sStyleName ) )
214 Reference< XNameAccess > xStyleFamily( xStyleFamilies->getByName( sFamilyName ), UNO_QUERY_THROW );
215 return Reference< XPropertySet >( xStyleFamily->getByName( sStyleName ), UNO_QUERY_THROW );
221 DBG_ASSERT( _rxControlModel.is(),
"ControlLayouter::initializeControlLayout: invalid model!" );
222 if ( !_rxControlModel.is() )
227 Reference< XPropertySetInfo > xPSI( _rxControlModel->getPropertySetInfo(), UNO_SET_THROW );
230 sal_Int16 nClassId = FormComponentType::CONTROL;
238 OConfigurationNode aConfig = getLayoutSettings( _eDocType );
239 Any aVisualEffect = aConfig.getNodeValue( OUString(
"VisualEffect" ) );
240 if ( aVisualEffect.hasValue() )
242 OUString sVisualEffect;
243 OSL_VERIFY( aVisualEffect >>= sVisualEffect );
245 sal_Int16 nVisualEffect = VisualEffect::NONE;
246 if ( sVisualEffect ==
"flat" )
247 nVisualEffect = VisualEffect::FLAT;
248 else if ( sVisualEffect ==
"3D" )
249 nVisualEffect = VisualEffect::LOOK3D;
253 if ( ( nClassId != FormComponentType::COMMANDBUTTON )
254 && ( nClassId != FormComponentType::RADIOBUTTON )
255 && ( nClassId != FormComponentType::CHECKBOX )
256 && ( nClassId != FormComponentType::GROUPBOX )
257 && ( nClassId != FormComponentType::FIXEDTEXT )
258 && ( nClassId != FormComponentType::SCROLLBAR )
259 && ( nClassId != FormComponentType::SPINBUTTON )
263 if ( ( nVisualEffect == VisualEffect::FLAT )
279 lcl_initializeControlFont( _rxControlModel );
281 catch(
const Exception& )
289 OConfigurationNode aConfig = getLayoutSettings( _eDocType );
290 Any aDynamicBorderColor = aConfig.getNodeValue( OUString(
"DynamicBorderColors" ) );
291 bool bDynamicBorderColor =
false;
292 OSL_VERIFY( aDynamicBorderColor >>= bDynamicBorderColor );
293 return bDynamicBorderColor;
301 OConfigurationNode aConfig = getLayoutSettings( _eDocType );
302 Any aUseRefDevice = aConfig.getNodeValue( OUString(
"UseDocumentTextMetrics" ) );
303 bool bUseRefDevice =
false;
304 OSL_VERIFY( aUseRefDevice >>= bUseRefDevice );
305 return bUseRefDevice;
LanguageType getLanguageType(bool bResolveSystem=true) const
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
const LanguageTag & getLanguageTag() const
static sal_Int16 getScriptType(LanguageType nLang)
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
const LocaleDataWrapper & GetLocaleData() const
static css::awt::FontDescriptor CreateFontDescriptor(const vcl::Font &rFont)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
constexpr OUStringLiteral FM_PROP_CLASSID
constexpr OUStringLiteral FM_PROP_BORDERCOLOR
constexpr OUStringLiteral FM_PROP_VISUALEFFECT
constexpr OUStringLiteral FM_PROP_FONT
constexpr OUStringLiteral FM_PROP_BORDER
class SAL_NO_VTABLE XPropertySet