From 3ba25e534d5a433778a6d6c77117a13c6d796761 Mon Sep 17 00:00:00 2001 From: Zolnai Tamás Date: Wed, 11 Jun 2014 12:36:26 +0200 Subject: Introduce HAVE_FEATURE_GLTF to enable/disable gltf related code When it is a release build then enable it only on Windows and Linux. Change-Id: I7c462aeb75e6ab60eeaa0fa42ca7853a6369b742 (cherry picked from commit fe70101856332663f600df144b39d2638b3d0570) --- avmedia/Library_avmedia.mk | 7 ++++++- avmedia/source/inc/mediamisc.hxx | 5 +++++ avmedia/source/viewer/mediawindow_impl.cxx | 9 +++++++++ config_host/config_features.h.in | 5 +++++ configure.ac | 8 +++++++- sd/qa/unit/data/media_embedding.odp | Bin 216243 -> 4068424 bytes sd/qa/unit/import-tests.cxx | 18 +++++++++++++++--- sd/source/ui/func/fuinsert.cxx | 8 ++++++-- sd/source/ui/inc/fuinsert.hxx | 5 +++-- sd/source/ui/view/drviews2.cxx | 5 ++++- sd/source/ui/view/drviews7.cxx | 10 ++++++++++ sd/source/ui/view/sdview4.cxx | 4 ++++ slideshow/source/engine/shapes/viewmediashape.cxx | 2 ++ svx/source/svdraw/svdomedia.cxx | 6 ++++++ xmloff/source/draw/shapeexport.cxx | 6 ++++++ xmloff/source/draw/ximpshap.cxx | 13 +++++++++---- 16 files changed, 97 insertions(+), 14 deletions(-) diff --git a/avmedia/Library_avmedia.mk b/avmedia/Library_avmedia.mk index 40ba35bbf976..63e9067ec38c 100644 --- a/avmedia/Library_avmedia.mk +++ b/avmedia/Library_avmedia.mk @@ -47,6 +47,12 @@ $(eval $(call gb_Library_use_libraries,avmedia,\ $(gb_UWINAPI) \ )) +ifeq ($(ENABLE_GLTF),TRUE) +$(eval $(call gb_Library_add_exception_objects,avmedia,\ + avmedia/source/framework/modeltools \ +)) +endif + ifneq (,$(filter COLLADA2GLTF,$(BUILD_TYPE))) $(eval $(call gb_Library_set_warnings_not_errors,avmedia)) @@ -74,7 +80,6 @@ $(eval $(call gb_Library_add_exception_objects,avmedia,\ avmedia/source/framework/mediamisc \ avmedia/source/framework/mediaplayer \ avmedia/source/framework/mediatoolbox \ - avmedia/source/framework/modeltools \ avmedia/source/framework/soundhandler \ avmedia/source/viewer/mediaevent_impl \ avmedia/source/viewer/mediawindow \ diff --git a/avmedia/source/inc/mediamisc.hxx b/avmedia/source/inc/mediamisc.hxx index 38a1e9db3f96..06e40665cc76 100644 --- a/avmedia/source/inc/mediamisc.hxx +++ b/avmedia/source/inc/mediamisc.hxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + #ifndef INCLUDED_AVMEDIA_SOURCE_INC_MEDIAMISC_HXX #define INCLUDED_AVMEDIA_SOURCE_INC_MEDIAMISC_HXX @@ -42,7 +44,10 @@ class ResMgr; // Mime types #define AVMEDIA_MIMETYPE_COMMON "application/vnd.sun.star.media" + +#if HAVE_FEATURE_GLTF #define AVMEDIA_MIMETYPE_JSON "application/vnd.gltf+json" +#endif namespace avmedia diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx index 834e5a524cbb..6254519ce5d2 100644 --- a/avmedia/source/viewer/mediawindow_impl.cxx +++ b/avmedia/source/viewer/mediawindow_impl.cxx @@ -16,6 +16,9 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ + +#include + #include #include "mediawindow_impl.hxx" #include "mediaevent_impl.hxx" @@ -83,10 +86,12 @@ MediaChildWindow::MediaChildWindow( Window* pParent ) : { } +#if HAVE_FEATURE_GLTF MediaChildWindow::MediaChildWindow( Window* pParent, SystemWindowData* pData ) : SystemChildWindow( pParent, WB_CLIPCHILDREN, pData ) { } +#endif MediaChildWindow::~MediaChildWindow() { @@ -242,10 +247,12 @@ uno::Reference< media::XPlayer > MediaWindowImpl::createPlayer( const OUString& xPlayer = createPlayer(rURL, aServiceName, xContext); } } +#if HAVE_FEATURE_GLTF else if ( *pMimeType == AVMEDIA_MIMETYPE_JSON ) { xPlayer = createPlayer(rURL, AVMEDIA_OPENGL_MANAGER_SERVICE_NAME, xContext); } +#endif return xPlayer; } @@ -507,12 +514,14 @@ void MediaWindowImpl::onURLChanged() { mpChildWindow.reset(new MediaChildWindow(this) ); } +#if HAVE_FEATURE_GLTF else if ( m_sMimeType == AVMEDIA_MIMETYPE_JSON ) { SystemWindowData aWinData = OpenGLContext::generateWinData(this); mpChildWindow.reset(new MediaChildWindow(this,&aWinData)); mbEventTransparent = false; } +#endif if( !mpChildWindow ) return; mpChildWindow->SetHelpId( HID_AVMEDIA_PLAYERWINDOW ); diff --git a/config_host/config_features.h.in b/config_host/config_features.h.in index 55232c64d066..3fd1da5b5dce 100644 --- a/config_host/config_features.h.in +++ b/config_host/config_features.h.in @@ -137,4 +137,9 @@ */ #define HAVE_EXPORT_VALIDATION 0 +/* + * Whether we have glTF support. + */ +#define HAVE_FEATURE_GLTF 0 + #endif diff --git a/configure.ac b/configure.ac index 3eba31da0fb0..752cbb0e7643 100644 --- a/configure.ac +++ b/configure.ac @@ -10526,12 +10526,18 @@ AC_SUBST(ENABLE_OPENCL) dnl =================================================================== dnl Check whether to enable glTF support dnl =================================================================== +AC_MSG_CHECKING([whether to enable glTF support]) +if test "$ENABLE_RELEASE_BUILD" = "TRUE"; then + if test $_os == iOS -o $_os == Android -o $_os = Darwin; then + enable_gltf=no + fi +fi ENABLE_GLTF= -AC_MSG_CHECKING([whether to enable glTF support]) if test "x$enable_gltf" != "xno"; then ENABLE_GLTF=TRUE AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_FEATURE_GLTF,1) BUILD_TYPE="$BUILD_TYPE LIBGLTF" if test "$test_freetype" = "no"; then BUILD_TYPE="$BUILD_TYPE FREETYPE" diff --git a/sd/qa/unit/data/media_embedding.odp b/sd/qa/unit/data/media_embedding.odp index 14ea4606448c..e70300edba59 100644 Binary files a/sd/qa/unit/data/media_embedding.odp and b/sd/qa/unit/data/media_embedding.odp differ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index cc9339acda69..949bd853e8a1 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -46,6 +47,8 @@ #include #include +#include + using namespace ::com::sun::star; /// Impress import filters tests. @@ -715,17 +718,26 @@ void SdFiltersTest::testMediaEmbedding() const SdrPage *pPage = pDoc->GetPage (1); CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL ); +#if HAVE_FEATURE_GLTF // First object is a glTF model - SdrMediaObj *pModelObj = dynamic_cast( pPage->GetObj( 1 )); + SdrMediaObj *pModelObj = dynamic_cast( pPage->GetObj( 2 )); CPPUNIT_ASSERT_MESSAGE( "missing model", pModelObj != NULL); - CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Model/duck/duck.json" ), pModelObj->getMediaProperties().getURL()); + CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Model/jeep/jeep.json" ), pModelObj->getMediaProperties().getURL()); CPPUNIT_ASSERT_EQUAL( OUString( "application/vnd.gltf+json" ), pModelObj->getMediaProperties().getMimeType()); +#else + // If glTF is not supported, then the fallback image is imported + SdrGrafObj *pGrafic = dynamic_cast( pPage->GetObj( 2 )); + CPPUNIT_ASSERT_MESSAGE( "Could not load glTF fallback image", pGrafic != NULL); + CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Pictures/jeep.png" ), pGrafic->GetGrafStreamURL()); +#endif // Second object is a sound - SdrMediaObj *pMediaObj = dynamic_cast( pPage->GetObj( 2 )); + SdrMediaObj *pMediaObj = dynamic_cast( pPage->GetObj( 3 )); CPPUNIT_ASSERT_MESSAGE( "missing media object", pMediaObj != NULL); CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Media/button-1.wav" ), pMediaObj->getMediaProperties().getURL()); CPPUNIT_ASSERT_EQUAL( OUString( "application/vnd.sun.star.media" ), pMediaObj->getMediaProperties().getMimeType()); + + xDocShRef->DoClose(); } void SdFiltersTest::testBnc870237() diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx index c16e6fc0e62b..c7bd348aa617 100644 --- a/sd/source/ui/func/fuinsert.cxx +++ b/sd/source/ui/func/fuinsert.cxx @@ -85,6 +85,8 @@ #include #include "glob.hrc" +#include + using namespace com::sun::star; namespace sd { @@ -93,7 +95,6 @@ TYPEINIT1( FuInsertGraphic, FuPoor ); TYPEINIT1( FuInsertClipboard, FuPoor ); TYPEINIT1( FuInsertOLE, FuPoor ); TYPEINIT1( FuInsertAVMedia, FuPoor ); -TYPEINIT1( FuInsert3DModel, FuPoor ); FuInsertGraphic::FuInsertGraphic ( ViewShell* pViewSh, @@ -763,6 +764,9 @@ void FuInsertAVMedia::DoExecute( SfxRequest& rReq ) } } +#if HAVE_FEATURE_GLTF +TYPEINIT1( FuInsert3DModel, FuPoor ); + FuInsert3DModel::FuInsert3DModel( ViewShell* pViewSh, ::sd::Window* pWin, @@ -826,7 +830,7 @@ void FuInsert3DModel::DoExecute( SfxRequest& ) mpWindow->LeaveWait(); } } - +#endif } // end of namespace sd /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/inc/fuinsert.hxx b/sd/source/ui/inc/fuinsert.hxx index 60276cd146a6..25b7ed329312 100644 --- a/sd/source/ui/inc/fuinsert.hxx +++ b/sd/source/ui/inc/fuinsert.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SD_SOURCE_UI_INC_FUINSERT_HXX #include "fupoor.hxx" +#include namespace sd { @@ -104,7 +105,7 @@ private: SdDrawDocument* pDoc, SfxRequest& rReq); }; - +#if HAVE_FEATURE_GLTF class FuInsert3DModel : public FuPoor { @@ -122,7 +123,7 @@ private: SdDrawDocument* pDoc, SfxRequest& rReq); }; - +#endif } // end of namespace sd #endif diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 7a6c14f7c935..384a6c7da817 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -32,6 +32,8 @@ #include +#include + #include #include #include @@ -1166,7 +1168,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) Invalidate(SID_DRAWTBX_INSERT); } break; - +#if HAVE_FEATURE_GLTF case SID_INSERT_3DMODEL: { SetCurrentFunction( FuInsert3DModel::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) ); @@ -1177,6 +1179,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) Invalidate(SID_DRAWTBX_INSERT); } break; +#endif case SID_COPYOBJECTS: { diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx index b0bec1dfd256..81e2e005a14c 100644 --- a/sd/source/ui/view/drviews7.cxx +++ b/sd/source/ui/view/drviews7.cxx @@ -80,6 +80,8 @@ #include "fubullet.hxx" #include "fuformatpaintbrush.hxx" +#include + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -1592,6 +1594,14 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) } } +#if !HAVE_FEATURE_GLTF + if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_INSERT_3DMODEL)) + { + rSet.DisableItem(SID_INSERT_3DMODEL); + rSet.Put(SfxVisibilityItem(SID_INSERT_3DMODEL, false)); + } +#endif + GetModeSwitchingMenuState (rSet); } diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx index c14465d6da56..e698e6457996 100644 --- a/sd/source/ui/view/sdview4.cxx +++ b/sd/source/ui/view/sdview4.cxx @@ -61,6 +61,8 @@ #include #include "glob.hrc" +#include + using namespace com::sun::star; namespace sd { @@ -289,6 +291,7 @@ SdrMediaObj* View::InsertMediaURL( const OUString& rMediaURL, sal_Int8& rAction, return InsertMediaObj( realURL, "application/vnd.sun.star.media", rAction, rPos, rSize ); } +#if HAVE_FEATURE_GLTF SdrMediaObj* View::Insert3DModelURL( const OUString& rModelURL, sal_Int8& rAction, const Point& rPos, const Size& rSize, @@ -313,6 +316,7 @@ SdrMediaObj* View::Insert3DModelURL( pRetObject->setMediaProperties(aItem); return pRetObject; } +#endif SdrMediaObj* View::InsertMediaObj( const OUString& rMediaURL, const OUString& rMimeType, sal_Int8& rAction, const Point& rPos, const Size& rSize ) diff --git a/slideshow/source/engine/shapes/viewmediashape.cxx b/slideshow/source/engine/shapes/viewmediashape.cxx index 344062d5a00d..45e29f70aca9 100644 --- a/slideshow/source/engine/shapes/viewmediashape.cxx +++ b/slideshow/source/engine/shapes/viewmediashape.cxx @@ -471,6 +471,7 @@ namespace slideshow rRangePix.getMinY(), rRangePix.getMaxX() - rRangePix.getMinX(), rRangePix.getMaxY() - rRangePix.getMinY() ); +#if HAVE_FEATURE_GLTF if( avmedia::IsModel(rMimeType) ) { mpEventHandlerParent.reset(new Window(pWindow, WB_NOBORDER|WB_NODIALOGCONTROL)); @@ -484,6 +485,7 @@ namespace slideshow Size( aAWTRect.Width, aAWTRect.Height ) ); } else +#endif { mpMediaWindow.reset( new SystemChildWindow( pWindow, WB_CLIPCHILDREN ) ); mpMediaWindow->SetPosSizePixel( Point( aAWTRect.X, aAWTRect.Y ), diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx index c05da8cdcc4f..e34a7285c90e 100644 --- a/svx/source/svdraw/svdomedia.cxx +++ b/svx/source/svdraw/svdomedia.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + #include #include @@ -263,6 +265,7 @@ uno::Reference SdrMediaObj::GetInputStream() return tempFile.openStream(); } +#if HAVE_FEATURE_GLTF static bool lcl_HandleJsonPackageURL( const OUString& rURL, SdrModel* const pModel, @@ -321,6 +324,7 @@ static bool lcl_HandleJsonPackageURL( } return true; } +#endif /// copy a stream from XStorage to temp file static bool lcl_HandlePackageURL( @@ -401,9 +405,11 @@ void SdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewProper { OUString tempFileURL; bool bSuccess; +#if HAVE_FEATURE_GLTF if( url.endsWith(".json") ) bSuccess = lcl_HandleJsonPackageURL(url, GetModel(), tempFileURL); else +#endif bSuccess = lcl_HandlePackageURL( url, GetModel(), tempFileURL); if (bSuccess) { diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 66577bac9594..0597ada5694c 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -114,6 +114,8 @@ #include "XMLImageMapExport.hxx" #include +#include + using namespace ::com::sun::star; using namespace ::xmloff::EnhancedCustomShapeToken; using namespace ::xmloff::token; @@ -3157,6 +3159,7 @@ lcl_StoreMediaAndGetURL(SvXMLExport & rExport, } } +#if HAVE_FEATURE_GLTF static void lcl_StoreJsonExternalsAndFallback( SvXMLExport& rExport, const uno::Reference xPropSet, @@ -3243,6 +3246,7 @@ static void lcl_StoreJsonExternalsAndFallback( } } } +#endif void XMLShapeExport::ImpExportMediaShape( const uno::Reference< drawing::XShape >& xShape, @@ -3270,8 +3274,10 @@ void XMLShapeExport::ImpExportMediaShape( OUString const persistentURL = lcl_StoreMediaAndGetURL(GetExport(), xPropSet, aMediaURL, sMimeType); +#if HAVE_FEATURE_GLTF if( sMimeType == "application/vnd.gltf+json" ) lcl_StoreJsonExternalsAndFallback(GetExport(), xPropSet, aMediaURL); +#endif mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, persistentURL ); mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE ); diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index 77d87bad09ff..d1c1b21ad93f 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -82,6 +82,8 @@ #include #include +#include + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::drawing; @@ -3065,10 +3067,12 @@ void SdXMLPluginShapeContext::StartElement( const ::com::sun::star::uno::Referen if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( aLocalName, XML_MIME_TYPE ) ) { - if( xAttrList->getValueByIndex( n ).equalsAscii( "application/vnd.sun.star.media" ) || - xAttrList->getValueByIndex( n ).equalsAscii( "application/vnd.gltf+json" )) + if( xAttrList->getValueByIndex( n ).equalsAscii( "application/vnd.sun.star.media" ) ) mbMedia = true; - +#if HAVE_FEATURE_GLTF + if( xAttrList->getValueByIndex( n ).equalsAscii( "application/vnd.gltf+json" ) ) + mbMedia = true; +#endif // leave this loop n = nAttrCount - 1; } @@ -3584,6 +3588,7 @@ SvXMLImportContext *SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPref } } } +#if HAVE_FEATURE_GLTF // For glTF models the fallback image is placed before the real shape. // So we need to remove the fallback image after real shape is detected. else if ( mxImplContext.Is() && IsXMLToken(mxImplContext->GetLocalName(), XML_IMAGE) && @@ -3596,7 +3601,7 @@ SvXMLImportContext *SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPref if( pContext ) removeGraphicFromImportContext(*mxImplContext); } - +#endif // call parent for content if(!pContext) pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList ); -- cgit