usingnamespace ::utl; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::XInterface; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::UNO_SET_THROW; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::uno::Any; using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::beans::XPropertySetInfo; using ::com::sun::star::lang::Locale; using ::com::sun::star::awt::FontDescriptor; using ::com::sun::star::style::XStyleFamiliesSupplier; using ::com::sun::star::lang::XServiceInfo; using ::com::sun::star::container::XNameAccess; using ::com::sun::star::container::XChild;
// determine the script type associated with the system locale const SvtSysLocale aSysLocale; const LocaleDataWrapper& rSysLocaleData = aSysLocale.GetLocaleData(); const sal_Int16 eSysLocaleScriptType = MsLangId::getScriptType( rSysLocaleData.getLanguageTag().getLanguageType() );
// depending on this script type, use the right property from the document's style which controls the // default locale for document content
OUString sCharLocalePropertyName = u"CharLocale"_ustr; switch ( eSysLocaleScriptType )
{ case ScriptType::LATIN: // already defaulted above break; case ScriptType::ASIAN:
sCharLocalePropertyName = u"CharLocaleAsian"_ustr; break; case ScriptType::COMPLEX:
sCharLocalePropertyName = u"CharLocaleComplex"_ustr; break; default:
OSL_FAIL( "lcl_initializeControlFont: unexpected script type for system locale!" ); break;
}
Locale aDocumentCharLocale; if ( xStylePSI->hasPropertyByName( sCharLocalePropertyName ) )
{
OSL_VERIFY( xStyle->getPropertyValue( sCharLocalePropertyName ) >>= aDocumentCharLocale );
} // fall back to CharLocale property at the style if ( aDocumentCharLocale.Language.isEmpty() )
{
sCharLocalePropertyName = "CharLocale"; if ( xStylePSI->hasPropertyByName( sCharLocalePropertyName ) )
{
OSL_VERIFY( xStyle->getPropertyValue( sCharLocalePropertyName ) >>= aDocumentCharLocale );
}
} // fall back to the system locale if ( aDocumentCharLocale.Language.isEmpty() )
{
aDocumentCharLocale = rSysLocaleData.getLanguageTag().getLocale();
}
// retrieve a default font for this locale, and set it at the control
vcl::Font aFont = OutputDevice::GetDefaultFont( DefaultFontType::SANS, LanguageTag::convertToLanguageType( aDocumentCharLocale ), GetDefaultFontFlags::OnlyOne );
FontDescriptor aFontDesc = VCLUnoHelper::CreateFontDescriptor( aFont );
_rxModel->setPropertyValue(u"FontDescriptor"_ustr, Any( aFontDesc )
);
} catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("svx");
}
}
}
// the names of the family, and the style - depends on the document type we live in
OUString sFamilyName, sStyleName; if ( !lcl_getDocumentDefaultStyleAndFamily( xSuppStyleFamilies, sFamilyName, sStyleName ) ) throw RuntimeException(u"unknown document type!"_ustr);
// the control type
sal_Int16 nClassId = FormComponentType::CONTROL;
_rxControlModel->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId;
// the document type if ( _eDocType == eUnknownDocumentType )
_eDocType = DocumentClassification::classifyHostDocument( _rxControlModel );
// let's see what the configuration says about the visual effect
OConfigurationNode aConfig = getLayoutSettings( _eDocType );
Any aVisualEffect = aConfig.getNodeValue( u"VisualEffect"_ustr ); if ( aVisualEffect.hasValue() )
{
OUString sVisualEffect;
OSL_VERIFY( aVisualEffect >>= sVisualEffect );
// the font (only if we use the document's ref devices for rendering control text, otherwise, the // default font from application or standard style is assumed to be fine) if ( useDocumentReferenceDevice( _eDocType )
&& xPSI->hasPropertyByName( FM_PROP_FONT )
)
lcl_initializeControlFont( _rxControlModel );
} catch( const Exception& )
{
TOOLS_WARN_EXCEPTION( "svx", "ControlLayouter::initializeControlLayout" );
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.