sd/source/ui/unoidl/unomodel.cxx | 58 +++++++++++++++++++++++++++++ xmloff/source/draw/sdxmlexp.cxx | 68 +++++++++++++++++++++++++++-------- xmloff/source/draw/sdxmlexp_impl.hxx | 1 3 files changed, 112 insertions(+), 15 deletions(-)
New commits: commit b40bcde076f9fabf24810d2520e878d604d99637 Author: Radek Doulik <[email protected]> Date: Fri Mar 1 13:03:06 2013 +0100 finish font embedding, use the new Fonts document property Change-Id: I4cd6b8c11fb1efe9f97d2c5e474bd0bdcc9ed505 diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index ca33ff0..5ffed47 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -1806,6 +1806,12 @@ void SdXMLExport::_ExportMeta() ////////////////////////////////////////////////////////////////////////////// +void SdXMLExport::_ExportFontDecls() +{ + GetFontAutoStylePool(); // make sure the pool is created + SvXMLExport::_ExportFontDecls(); +} + void SdXMLExport::_ExportContent() { // export <pres:header-decl>, <pres:footer-decl> and <pres:date-time-decl> elements @@ -2807,25 +2813,25 @@ uno::Reference< uno::XInterface > SAL_CALL classname##_createInstance(const uno: } SERVICE( XMLImpressExportOasis, "com.sun.star.comp.Impress.XMLOasisExporter", "XMLImpressExportOasis", sal_False, EXPORT_OASIS|EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED ); -SERVICE( XMLImpressStylesExportOasis, "com.sun.star.comp.Impress.XMLOasisStylesExporter", "XMLImpressStylesExportOasis", sal_False, EXPORT_OASIS|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES ); +SERVICE( XMLImpressStylesExportOasis, "com.sun.star.comp.Impress.XMLOasisStylesExporter", "XMLImpressStylesExportOasis", sal_False, EXPORT_OASIS|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS ); SERVICE( XMLImpressContentExportOasis, "com.sun.star.comp.Impress.XMLOasisContentExporter", "XMLImpressContentExportOasis", sal_False, EXPORT_OASIS|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS ); SERVICE( XMLImpressMetaExportOasis, "com.sun.star.comp.Impress.XMLOasisMetaExporter", "XMLImpressMetaExportOasis", sal_False, EXPORT_OASIS|EXPORT_META ); SERVICE( XMLImpressSettingsExportOasis, "com.sun.star.comp.Impress.XMLOasisSettingsExporter", "XMLImpressSettingsExportOasis", sal_False, EXPORT_OASIS|EXPORT_SETTINGS ); SERVICE( XMLImpressExportOOO, "com.sun.star.comp.Impress.XMLExporter", "XMLImpressExportOOO", sal_False, EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED ); -SERVICE( XMLImpressStylesExportOOO, "com.sun.star.comp.Impress.XMLStylesExporter", "XMLImpressStylesExportOOO", sal_False, EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES ); +SERVICE( XMLImpressStylesExportOOO, "com.sun.star.comp.Impress.XMLStylesExporter", "XMLImpressStylesExportOOO", sal_False, EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS ); SERVICE( XMLImpressContentExportOOO, "com.sun.star.comp.Impress.XMLContentExporter", "XMLImpressContentExportOOO", sal_False, EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS ); SERVICE( XMLImpressMetaExportOOO, "com.sun.star.comp.Impress.XMLMetaExporter", "XMLImpressMetaExportOOO", sal_False, EXPORT_META ); SERVICE( XMLImpressSettingsExportOOO, "com.sun.star.comp.Impress.XMLSettingsExporter", "XMLImpressSettingsExportOOO", sal_False, EXPORT_SETTINGS ); SERVICE( XMLDrawExportOasis, "com.sun.star.comp.Draw.XMLOasisExporter", "XMLDrawExportOasis", sal_True, EXPORT_OASIS|EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED ); -SERVICE( XMLDrawStylesExportOasis, "com.sun.star.comp.Draw.XMLOasisStylesExporter", "XMLDrawStylesExportOasis", sal_True, EXPORT_OASIS|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES ); +SERVICE( XMLDrawStylesExportOasis, "com.sun.star.comp.Draw.XMLOasisStylesExporter", "XMLDrawStylesExportOasis", sal_True, EXPORT_OASIS|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS ); SERVICE( XMLDrawContentExportOasis, "com.sun.star.comp.Draw.XMLOasisContentExporter", "XMLDrawContentExportOasis", sal_True, EXPORT_OASIS|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS ); SERVICE( XMLDrawMetaExportOasis, "com.sun.star.comp.Draw.XMLOasisMetaExporter", "XMLDrawMetaExportOasis", sal_True, EXPORT_OASIS|EXPORT_META ); SERVICE( XMLDrawSettingsExportOasis, "com.sun.star.comp.Draw.XMLOasisSettingsExporter", "XMLDrawSettingsExportOasis", sal_True, EXPORT_OASIS|EXPORT_SETTINGS ); SERVICE( XMLDrawExportOOO, "com.sun.star.comp.Draw.XMLExporter", "XMLDrawExportOOO", sal_True, EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED ); -SERVICE( XMLDrawStylesExportOOO, "com.sun.star.comp.Draw.XMLStylesExporter", "XMLDrawStylesExportOOO", sal_True, EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES ); +SERVICE( XMLDrawStylesExportOOO, "com.sun.star.comp.Draw.XMLStylesExporter", "XMLDrawStylesExportOOO", sal_True, EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS ); SERVICE( XMLDrawContentExportOOO, "com.sun.star.comp.Draw.XMLContentExporter", "XMLDrawContentExportOOO", sal_True, EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS ); SERVICE( XMLDrawMetaExportOOO, "com.sun.star.comp.Draw.XMLMetaExporter", "XMLDrawMetaExportOOO", sal_True, EXPORT_META ); SERVICE( XMLDrawSettingsExportOOO, "com.sun.star.comp.Draw.XMLSettingsExporter", "XMLDrawSettingsExportOOO", sal_True, EXPORT_SETTINGS ); @@ -2844,7 +2850,7 @@ OUString SAL_CALL SdXMLExport::getImplementationName() throw( uno::RuntimeExcept { case EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED: return XMLDrawExportOOO_getImplementationName(); - case EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES: + case EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS: return XMLDrawStylesExportOOO_getImplementationName(); case EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS: return XMLDrawContentExportOOO_getImplementationName(); @@ -2855,7 +2861,7 @@ OUString SAL_CALL SdXMLExport::getImplementationName() throw( uno::RuntimeExcept case EXPORT_OASIS|EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED: return XMLDrawExportOasis_getImplementationName(); - case EXPORT_OASIS|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES: + case EXPORT_OASIS|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS: return XMLDrawStylesExportOasis_getImplementationName(); case EXPORT_OASIS|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS: return XMLDrawContentExportOasis_getImplementationName(); @@ -2876,7 +2882,7 @@ OUString SAL_CALL SdXMLExport::getImplementationName() throw( uno::RuntimeExcept { case EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED: return XMLImpressExportOOO_getImplementationName(); - case EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES: + case EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS: return XMLImpressStylesExportOOO_getImplementationName(); case EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS: return XMLImpressContentExportOOO_getImplementationName(); @@ -2886,7 +2892,7 @@ OUString SAL_CALL SdXMLExport::getImplementationName() throw( uno::RuntimeExcept return XMLImpressSettingsExportOOO_getImplementationName(); case EXPORT_OASIS|EXPORT_META|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_SETTINGS|EXPORT_FONTDECLS|EXPORT_EMBEDDED: return XMLImpressExportOasis_getImplementationName(); - case EXPORT_OASIS|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES: + case EXPORT_OASIS|EXPORT_STYLES|EXPORT_MASTERSTYLES|EXPORT_AUTOSTYLES|EXPORT_FONTDECLS: return XMLImpressStylesExportOasis_getImplementationName(); case EXPORT_OASIS|EXPORT_AUTOSTYLES|EXPORT_CONTENT|EXPORT_SCRIPTS|EXPORT_FONTDECLS: return XMLImpressContentExportOasis_getImplementationName(); @@ -2904,14 +2910,46 @@ OUString SAL_CALL SdXMLExport::getImplementationName() throw( uno::RuntimeExcept XMLFontAutoStylePool* SdXMLExport::CreateFontAutoStylePool() { bool bEmbedFonts = false; - Reference< lang::XMultiServiceFactory > xFac( GetModel(), UNO_QUERY ); - if( xFac.is() ) - { - Reference< beans::XPropertySet > xProps( xFac->createInstance( OUString( "com.sun.star.document.Settings" ) ), UNO_QUERY ); - if( xProps.is() ) - xProps->getPropertyValue("EmbedFonts") >>= bEmbedFonts; + if( getExportFlags() & EXPORT_CONTENT ) { + Reference< lang::XMultiServiceFactory > xFac( GetModel(), UNO_QUERY ); + if( xFac.is() ) + { + Reference< beans::XPropertySet > xProps( xFac->createInstance( OUString( "com.sun.star.document.Settings" ) ), UNO_QUERY ); + if( xProps.is() ) + xProps->getPropertyValue("EmbedFonts") >>= bEmbedFonts; + + } } - return new XMLFontAutoStylePool( *this, bEmbedFonts ); + + XMLFontAutoStylePool *pPool = new XMLFontAutoStylePool( *this, bEmbedFonts ); + + Reference< beans::XPropertySet > xProps( GetModel(), UNO_QUERY ); + if ( xProps.is() ) { + Sequence<Any> aAnySeq; + if( xProps->getPropertyValue(OUString("Fonts")) >>= aAnySeq ) + { + if( aAnySeq.getLength() % 5 == 0 ) + { + int nLen = aAnySeq.getLength() / 5; + int nSeqIndex = 0; + for( int i = 0; i < nLen; i++ ) + { + OUString sFamilyName, sStyleName; + sal_Int16 eFamily, ePitch, eCharSet; + + aAnySeq[nSeqIndex++] >>= sFamilyName; + aAnySeq[nSeqIndex++] >>= sStyleName; + aAnySeq[nSeqIndex++] >>= eFamily; + aAnySeq[nSeqIndex++] >>= ePitch; + aAnySeq[nSeqIndex++] >>= eCharSet; + + pPool->Add( sFamilyName, sStyleName, FontFamily( eFamily ), FontPitch( ePitch ), rtl_TextEncoding( eCharSet ) ); + } + } + } + } + + return pPool; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/draw/sdxmlexp_impl.hxx b/xmloff/source/draw/sdxmlexp_impl.hxx index cc5a5ed..ccc34b2 100644 --- a/xmloff/source/draw/sdxmlexp_impl.hxx +++ b/xmloff/source/draw/sdxmlexp_impl.hxx @@ -136,6 +136,7 @@ class SdXMLExport : public SvXMLExport virtual void _ExportStyles(sal_Bool bUsed); virtual void _ExportAutoStyles(); + virtual void _ExportFontDecls(); virtual void _ExportMasterStyles(); virtual void _ExportContent(); // #82003# commit 8ad5c064190084cb46ce8847bfa306ce3cb01987 Author: Radek Doulik <[email protected]> Date: Fri Mar 1 13:02:12 2013 +0100 added new Fonts property, it is used in xmloff for fonts embedding Change-Id: I8a88fb8fd2048e8ced138f19e5bfa74c160c86eb diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index fbd341a..a49f9d4 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -50,6 +50,7 @@ #include <svx/unopool.hxx> #include <svx/svdorect.hxx> #include <editeng/flditem.hxx> +#include <editeng/fontitem.hxx> #include <toolkit/awt/vclxdevice.hxx> #include <svx/svdpool.hxx> #include <editeng/unolingu.hxx> @@ -172,6 +173,15 @@ const sal_Int32 WID_MODEL_RUNTIMEUID = 9; const sal_Int32 WID_MODEL_BUILDID = 10; const sal_Int32 WID_MODEL_HASVALIDSIGNATURES = 11; const sal_Int32 WID_MODEL_DIALOGLIBS = 12; +const sal_Int32 WID_MODEL_FONTS = 13; + +#ifndef SEQTYPE + #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500) + #define SEQTYPE(x) (new ::com::sun::star::uno::Type( x )) + #else + #define SEQTYPE(x) &(x) + #endif +#endif const SvxItemPropertySet* ImplGetDrawModelPropertySet() { @@ -190,6 +200,7 @@ const SvxItemPropertySet* ImplGetDrawModelPropertySet() { MAP_CHAR_LEN("DialogLibraries"), WID_MODEL_DIALOGLIBS, &::getCppuType((const uno::Reference< script::XLibraryContainer > *)0), beans::PropertyAttribute::READONLY, 0 }, { MAP_CHAR_LEN(sUNO_Prop_RuntimeUID), WID_MODEL_RUNTIMEUID, &::getCppuType(static_cast< const rtl::OUString * >(0)), beans::PropertyAttribute::READONLY, 0 }, { MAP_CHAR_LEN(sUNO_Prop_HasValidSignatures), WID_MODEL_HASVALIDSIGNATURES, &::getCppuType(static_cast< const sal_Bool * >(0)), beans::PropertyAttribute::READONLY, 0 }, + { MAP_CHAR_LEN("Fonts"), WID_MODEL_FONTS, SEQTYPE(::getCppuType((uno::Sequence<uno::Any>*)0)), beans::PropertyAttribute::READONLY, 0}, { 0,0,0,0,0,0 } }; static SvxItemPropertySet aDrawModelPropertySet_Impl( aDrawModelPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() ); @@ -1253,6 +1264,7 @@ void SAL_CALL SdXImpressDocument::setPropertyValue( const OUString& aPropertyNam case WID_MODEL_BASICLIBS: case WID_MODEL_RUNTIMEUID: // is read-only case WID_MODEL_DIALOGLIBS: + case WID_MODEL_FONTS: throw beans::PropertyVetoException(); default: throw beans::UnknownPropertyException(); @@ -1330,6 +1342,52 @@ uno::Any SAL_CALL SdXImpressDocument::getPropertyValue( const OUString& Property case WID_MODEL_HASVALIDSIGNATURES: aAny <<= hasValidSignatures(); break; + case WID_MODEL_FONTS: + { + uno::Sequence<uno::Any> aSeq; + int nSeqIndex = 0; + + sal_uInt16 aWhichIds[3] = { EE_CHAR_FONTINFO, EE_CHAR_FONTINFO_CJK, + EE_CHAR_FONTINFO_CTL }; + + const SfxItemPool& rPool = mpDoc->GetPool(); + const SfxPoolItem* pItem; + + for( sal_uInt16 i=0; i<3; i++ ) + { + sal_uInt16 nWhichId = aWhichIds[i]; + sal_uInt32 nItems = rPool.GetItemCount2( nWhichId ); + + aSeq.realloc( aSeq.getLength() + nItems*5 + 5 ); + + for( sal_uInt32 j = 0; j < nItems; ++j ) + { + if( 0 != (pItem = rPool.GetItem2( nWhichId, j ) ) ) + { + const SvxFontItem *pFont = (const SvxFontItem *)pItem; + + aSeq[nSeqIndex++] <<= OUString(pFont->GetFamilyName()); + aSeq[nSeqIndex++] <<= OUString(pFont->GetStyleName()); + aSeq[nSeqIndex++] <<= sal_Int16(pFont->GetFamily()); + aSeq[nSeqIndex++] <<= sal_Int16(pFont->GetPitch()); + aSeq[nSeqIndex++] <<= sal_Int16(pFont->GetCharSet()); + } + } + + const SvxFontItem& rFont = (const SvxFontItem&)rPool.GetDefaultItem( nWhichId ); + + aSeq[nSeqIndex++] <<= OUString(rFont.GetFamilyName()); + aSeq[nSeqIndex++] <<= OUString(rFont.GetStyleName()); + aSeq[nSeqIndex++] <<= sal_Int16(rFont.GetFamily()); + aSeq[nSeqIndex++] <<= sal_Int16(rFont.GetPitch()); + aSeq[nSeqIndex++] <<= sal_Int16(rFont.GetCharSet()); + + } + + aSeq.realloc( nSeqIndex ); + aAny <<= aSeq; + break; + } default: throw beans::UnknownPropertyException(); } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
