merge 3 copy and paste efforts back together as bestFitOpenSymbolToMSFont
Change-Id: Ia830af58a1e2b80e85b2748b4acceb0bfc340afc
diff --git a/filter/inc/filter/msfilter/util.hxx b/filter/inc/filter/msfilter/util.hxx
index ff52209..d772a24 100644
--- a/filter/inc/filter/msfilter/util.hxx
+++ b/filter/inc/filter/msfilter/util.hxx
@@ -59,6 +59,17 @@ to find it, unfortunately :-(
*/
MSFILTER_DLLPUBLIC rtl::OString DateTimeToOString( const DateTime& rDateTime );
/// Given a cBullet in encoding r_ioChrSet and fontname r_ioFontName return a
/// suitable new Bullet and change r_ioChrSet and r_ioFontName to form the
/// best-fit replacement in terms of default available MSOffice symbol
/// fonts.
///
/// Set bDisableUnicodeSupport when exporting to 8bit encodings
///
/// Used to map from [Open|Star]Symbol to some Windows font or other.
MSFILTER_DLLPUBLIC sal_Unicode bestFitOpenSymbolToMSFont(sal_Unicode cBullet,
rtl_TextEncoding& r_ioChrSet, rtl::OUString& r_ioFontName, bool bDisableUnicodeSupport = false);
}
}
diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx
index adfe4922..ddb9f14 100644
--- a/filter/source/msfilter/util.cxx
+++ b/filter/source/msfilter/util.cxx
@@ -28,6 +28,8 @@
#include <rtl/ustring.hxx>
#include <rtl/strbuf.hxx>
#include <unotools/fontcvt.hxx>
#include <unotools/fontdefs.hxx>
#include <vcl/svapp.hxx>
#include <filter/msfilter/util.hxx>
@@ -140,6 +142,43 @@ rtl::OString DateTimeToOString( const DateTime& rDateTime )
return aBuffer.makeStringAndClear();
}
sal_Unicode bestFitOpenSymbolToMSFont(sal_Unicode cChar,
rtl_TextEncoding& rChrSet, rtl::OUString& rFontName, bool bDisableUnicodeSupport)
{
StarSymbolToMSMultiFont *pConvert = CreateStarSymbolToMSMultiFont();
rtl::OUString sFont = pConvert->ConvertChar(cChar);
delete pConvert;
if (!sFont.isEmpty())
{
cChar = static_cast< sal_Unicode >(cChar | 0xF000);
rFontName = sFont;
rChrSet = RTL_TEXTENCODING_SYMBOL;
}
else if (!bDisableUnicodeSupport && (cChar < 0xE000 || cChar > 0xF8FF))
{
/*
Ok we can't fit into a known windows unicode font, but
we are not in the private area, so we are a
standardized symbol, so turn off the symbol bit and
let words own font substitution kick in
*/
rChrSet = RTL_TEXTENCODING_UNICODE;
xub_StrLen nIndex = 0;
rFontName = ::GetNextFontToken(rFontName, nIndex);
}
else
{
/*
Well we don't have an available substition, and we're
in our private area, so give up and show a standard
bullet symbol
*/
rFontName = "Wingdings";
cChar = static_cast< sal_Unicode >(0x6C);
}
return cChar;
}
}
}
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index aae83ab..c4396fe 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -66,15 +66,15 @@
#include <com/sun/star/text/XTextRange.hpp>
#include <tools/stream.hxx>
#include <tools/string.hxx>
#include <vcl/cvtgrf.hxx>
#include <unotools/fontcvt.hxx>
#include <unotools/fontdefs.hxx>
#include <vcl/cvtgrf.hxx>
#include <vcl/graph.hxx>
#include <svtools/grfmgr.hxx>
#include <rtl/strbuf.hxx>
#include <sfx2/app.hxx>
#include <svl/languageoptions.hxx>
#include <filter/msfilter/escherex.hxx>
#include <filter/msfilter/util.hxx>
#include <editeng/svxenum.hxx>
using namespace ::com::sun::star;
@@ -1427,59 +1427,17 @@ void DrawingML::WriteConnectorConnections( EscherConnectorListEntry& rConnectorE
FSEND );
}
// from sw/source/filter/ww8/wrtw8num.cxx for default bullets to export to MS intact
static void lcl_SubstituteBullet(String& rNumStr, rtl_TextEncoding& rChrSet, String& rFontName)
{
sal_Unicode cChar = rNumStr.GetChar(0);
StarSymbolToMSMultiFont *pConvert = CreateStarSymbolToMSMultiFont();
String sFont = pConvert->ConvertChar(cChar);
delete pConvert;
if (sFont.Len())
{
rNumStr = static_cast< sal_Unicode >(cChar | 0xF000);
rFontName = sFont;
rChrSet = RTL_TEXTENCODING_SYMBOL;
}
else if ( (rNumStr.GetChar(0) < 0xE000 || rNumStr.GetChar(0) > 0xF8FF) )
{
/*
Ok we can't fit into a known windows unicode font, but
we are not in the private area, so we are a
standardized symbol, so turn off the symbol bit and
let words own font substitution kick in
*/
rChrSet = RTL_TEXTENCODING_UNICODE;
xub_StrLen nIndex = 0;
rFontName = ::GetNextFontToken(rFontName, nIndex);
}
else
{
/*
Well we don't have an available substition, and we're
in our private area, so give up and show a standard
bullet symbol
*/
rFontName.AssignAscii(RTL_CONSTASCII_STRINGPARAM("Wingdings"));
rNumStr = static_cast< sal_Unicode >(0x6C);
}
}
sal_Unicode DrawingML::SubstituteBullet( sal_Unicode cBulletId, ::com::sun::star::awt::FontDescriptor& rFontDesc )
{
String sNumStr = cBulletId;
if ( rFontDesc.Name.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("starsymbol")) ||
rFontDesc.Name.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("opensymbol")) ) {
String sFontName = rFontDesc.Name;
rtl_TextEncoding aCharSet = rFontDesc.CharSet;
lcl_SubstituteBullet( sNumStr, aCharSet, sFontName );
rFontDesc.Name = sFontName;
rFontDesc.CharSet = aCharSet;
rFontDesc.Name.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("opensymbol")) )
{
rtl_TextEncoding eCharSet = rFontDesc.CharSet;
cBulletId = msfilter::util::bestFitOpenSymbolToMSFont(cBulletId, eCharSet, rFontDesc.Name);
rFontDesc.CharSet = eCharSet;
}
return sNumStr.GetChar( 0 );
return cBulletId;
}
sax_fastparser::FSHelperPtr DrawingML::CreateOutputStream (
diff --git a/sd/source/filter/eppt/pptx-text.cxx b/sd/source/filter/eppt/pptx-text.cxx
index 5f9a08c..f264c7c 100644
--- a/sd/source/filter/eppt/pptx-text.cxx
+++ b/sd/source/filter/eppt/pptx-text.cxx
@@ -48,11 +48,11 @@
#include <comphelper/processfactory.hxx>
#include <editeng/svxenum.hxx>
#include <editeng/frmdir.hxx>
#include <filter/msfilter/util.hxx>
#include <i18nutil/scripttypedetector.hxx>
#include <sfx2/app.hxx>
#include <svl/languageoptions.hxx>
#include <oox/export/drawingml.hxx> // for SubstituteBullet
#include <unotools/fontcvt.hxx>
#include <vcl/metric.hxx>
#include <vcl/outdev.hxx>
#include <vcl/virdev.hxx>
@@ -746,43 +746,6 @@ void ParagraphObj::CalculateGraphicBulletSize( sal_uInt16 nFontHeight )
}
}
// from sw/source/filter/ww8/wrtw8num.cxx for default bullets to export to MS intact
static void lcl_SubstituteBullet(rtl::OUString& rNumStr, rtl_TextEncoding& rChrSet, rtl::OUString& rFontName)
{
sal_Unicode cChar = rNumStr[0];
StarSymbolToMSMultiFont *pConvert = CreateStarSymbolToMSMultiFont();
rtl::OUString sFont = pConvert->ConvertChar(cChar);
delete pConvert;
if (!sFont.isEmpty())
{
rNumStr = rtl::OUString(static_cast< sal_Unicode >(cChar | 0xF000));
rFontName = sFont;
rChrSet = RTL_TEXTENCODING_SYMBOL;
}
else if ( (rNumStr[0] < 0xE000 || rNumStr[0] > 0xF8FF) )
{
/*
Ok we can't fit into a known windows unicode font, but
we are not in the private area, so we are a
standardized symbol, so turn off the symbol bit and
let words own font substitution kick in
*/
rChrSet = RTL_TEXTENCODING_UNICODE;
xub_StrLen nIndex = 0;
rFontName = ::GetNextFontToken(rFontName, nIndex);
}
else
{
/*
Well we don't have an available substition, and we're
in our private area, so give up and show a standard
bullet symbol
*/
rFontName = "Wingdings";
rNumStr = rtl::OUString(static_cast< sal_Unicode >(0x6C));
}
}
void ParagraphObj::ImplGetNumberingLevel( PPTExBulletProvider& rBuProv, sal_Int16 nNumberingDepth, sal_Bool bIsBullet, sal_Bool bGetPropStateValue )
{
::com::sun::star::uno::Any aAny;
@@ -930,16 +893,12 @@ void ParagraphObj::ImplGetNumberingLevel( PPTExBulletProvider& rBuProv, sal_Int1
case SVX_NUM_CHAR_SPECIAL : // Bullet
{
if ( aFontDesc.Name.equals("starsymbol") || aFontDesc.Name.equals("opensymbol") )
if ( aFontDesc.Name.equals("starsymbol") || aFontDesc.Name.equals("opensymbol") )
{
rtl::OUString sFontName(aFontDesc.Name);
rtl::OUString sNumStr(cBulletId);
rtl_TextEncoding eChrSet = aFontDesc.CharSet;
lcl_SubstituteBullet(sNumStr,eChrSet,sFontName);
aFontDesc.Name = sFontName;
cBulletId = sNumStr[ 0 ];
cBulletId = msfilter::util::bestFitOpenSymbolToMSFont(cBulletId, eChrSet, aFontDesc.Name);
aFontDesc.CharSet = eChrSet;
}
}
if ( !aFontDesc.Name.isEmpty() )
{
diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx
index 5e22ae0..2ac82b1 100644
--- a/sw/source/filter/ww8/wrtw8num.cxx
+++ b/sw/source/filter/ww8/wrtw8num.cxx
@@ -693,48 +693,12 @@ void WW8Export::BuildAnlvBulletBase(WW8_ANLV& rAnlv, sal_uInt8*& rpCh,
void MSWordExportBase::SubstituteBullet( String& rNumStr,
rtl_TextEncoding& rChrSet, String& rFontName ) const
{
StarSymbolToMSMultiFont *pConvert = 0;
if (!bSubstituteBullets)
return;
if (!pConvert)
{
pConvert = CreateStarSymbolToMSMultiFont();
}
sal_Unicode cChar = rNumStr.GetChar(0);
String sFont = pConvert->ConvertChar(cChar);
if (sFont.Len())
{
rNumStr = static_cast< sal_Unicode >(cChar | 0xF000);
rFontName = sFont;
rChrSet = RTL_TEXTENCODING_SYMBOL;
}
else if ( SupportsUnicode() &&
(rNumStr.GetChar(0) < 0xE000 || rNumStr.GetChar(0) > 0xF8FF) )
{
/*
Ok we can't fit into a known windows unicode font, but
we are not in the private area, so we are a
standardized symbol, so turn off the symbol bit and
let words own font substitution kick in
*/
rChrSet = RTL_TEXTENCODING_UNICODE;
xub_StrLen nIndex = 0;
rFontName = ::GetNextFontToken(rFontName, nIndex);
}
else
{
/*
Well we don't have an available substition, and we're
in our private area, so give up and show a standard
bullet symbol
*/
rFontName.ASSIGN_CONST_ASC("Wingdings");
rNumStr = static_cast< sal_Unicode >(0x6C);
}
delete pConvert;
rtl::OUString sFontName = rFontName;
rNumStr.SetChar(0, msfilter::util::bestFitOpenSymbolToMSFont(rNumStr.GetChar(0),
rChrSet, sFontName, !SupportsUnicode()));
rFontName = sFontName;
}
static void SwWw8_InsertAnlText( const String& rStr, sal_uInt8*& rpCh,