fdo#67957: Font name reported in AXFont always Times New Roman

This is a partial fix. Now VoiceOver does report changes in font faces
but it works correctly only when the paragraph text style has font
"Times New Roman". If it has not, then parts of the text with
"Times New Roman" have not change in font reported, but parts with
font different both from the paragraph style font and "Times New Roman"
do have font change reported.

In other words, the default font for paragraph is still "Times New Roman"
in accessibility even though sometimes it's not true.

This also fixes font size being reported only when bold or italic is set,
and has more robustness for handling mixed bold/italic when at least one
of them is set in the paragraph style as well.

Change-Id: Id0715727d04cd9b814aa0e4093939cd3e6abe897
Reviewed-on: https://gerrit.libreoffice.org/5344
Reviewed-by: Tor Lillqvist <tml@iki.fi>
Tested-by: Tor Lillqvist <tml@iki.fi>
This commit is contained in:
Boris Dušek
2013-08-11 08:44:26 +02:00
committed by Tor Lillqvist
parent 38aad8c3a7
commit 3e9ae4da94
3 changed files with 28 additions and 4 deletions

View File

@@ -50,7 +50,7 @@ using namespace ::rtl;
}
+(int)convertBoldStyle:(PropertyValue)property {
int boldStyle = 0;
int boldStyle = NSUnboldFontMask;
float value = 0;
property.Value >>= value;
if ( value == ::css_awt::FontWeight::SEMIBOLD
@@ -63,7 +63,7 @@ using namespace ::rtl;
}
+(int)convertItalicStyle:(PropertyValue)property {
int italicStyle = 0;
int italicStyle = NSUnitalicFontMask;
sal_Int16 value = property.Value.get< ::css_awt::FontSlant>();
if ( value == ::css_awt::FontSlant_ITALIC ) {
italicStyle = NSItalicFontMask;
@@ -198,10 +198,22 @@ using namespace ::rtl;
if ( wrapperStore != nil ) { // default
[ wrapperStore setDefaultFontname: CreateNSString ( fontname ) ];
[ wrapperStore setDefaultFontsize: fontsize ];
[ wrapperStore setDefaultFonttraits: fonttraits ];
NSFont * font = [ [ NSFontManager sharedFontManager ] fontWithFamily: CreateNSString ( fontname ) traits: fonttraits weight: 0 size: fontsize ];
[ AquaA11yTextAttributesWrapper addFont: font toString: string forRange: range ];
} else if ( wrapper != nil && fonttraits != 0 ) { // attribute run and bold and/or italic was found
NSFont * font = [ [ NSFontManager sharedFontManager ] fontWithFamily: [ wrapper defaultFontname ] traits: fonttraits weight: 0 size: [ wrapper defaultFontsize ] ];
} else if ( wrapper != nil) { // attribute run and bold and/or italic was found
NSString *fontName = nil;
if (fontname.isEmpty())
fontName = [wrapper defaultFontname];
else
fontName = CreateNSString(fontname);
if (!(fonttraits & (NSBoldFontMask | NSUnboldFontMask)))
fonttraits |= [wrapper defaultFonttraits] & (NSBoldFontMask | NSUnboldFontMask);
if (!(fonttraits & (NSItalicFontMask | NSUnitalicFontMask)))
fonttraits |= [wrapper defaultFonttraits] & (NSItalicFontMask | NSUnitalicFontMask);
if (fontsize == 0.0)
fontsize = [wrapper defaultFontsize];
NSFont * font = [ [ NSFontManager sharedFontManager ] fontWithFamily: fontName traits: fonttraits weight: 0 size: fontsize ];
[ AquaA11yTextAttributesWrapper addFont: font toString: string forRange: range ];
}
[ pool release ];

View File

@@ -82,6 +82,7 @@ static std::ostream &operator<<(std::ostream &s, NSPoint point) {
-(void) setDefaults: (Reference < XAccessibleContext >) rxAccessibleContext {
mDefaultFontsize = 0.0;
mDefaultFonttraits = 0;
mpDefaultFontname = nil;
mpReferenceWrapper = new ReferenceWrapper;
mActsAsRadioGroup = NO;
@@ -1145,6 +1146,14 @@ Reference < XAccessibleContext > hitTestRunner ( com::sun::star::awt::Point poin
return mDefaultFontsize;
}
-(void)setDefaultFonttraits:(int)fonttraits {
mDefaultFonttraits = fonttraits;
}
-(int)defaultFonttraits {
return mDefaultFonttraits;
}
-(void)setActsAsRadioGroup:(BOOL)actsAsRadioGroup {
mActsAsRadioGroup = actsAsRadioGroup;
}

View File

@@ -54,6 +54,7 @@ struct ReferenceWrapper
ReferenceWrapper * mpReferenceWrapper;
NSString * mpDefaultFontname;
float mDefaultFontsize;
int mDefaultFonttraits;
BOOL mActsAsRadioGroup;
BOOL mIsTableCell;
}
@@ -94,6 +95,8 @@ struct ReferenceWrapper
-(NSString *)defaultFontname;
-(void)setDefaultFontsize:(float)fontsize;
-(float)defaultFontsize;
-(void)setDefaultFonttraits:(int)fonttraits;
-(int)defaultFonttraits;
+(void)setPopupMenuOpen:(BOOL)popupMenuOpen;
-(::com::sun::star::accessibility::XAccessibleAction *)accessibleAction;
-(::com::sun::star::accessibility::XAccessibleContext *)accessibleContext;