incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r1182525 - /incubator/ooo/trunk/main/svx/source/unogallery/unogaltheme.cxx
Date Wed, 12 Oct 2011 19:03:14 GMT
Author: pfg
Date: Wed Oct 12 19:03:14 2011
New Revision: 1182525

URL: http://svn.apache.org/viewvc?rev=1182525&view=rev
Log:
i80184 - can't add SVG draw documents to gallery via API

Modified:
    incubator/ooo/trunk/main/svx/source/unogallery/unogaltheme.cxx

Modified: incubator/ooo/trunk/main/svx/source/unogallery/unogaltheme.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/unogallery/unogaltheme.cxx?rev=1182525&r1=1182524&r2=1182525&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/unogallery/unogaltheme.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/unogallery/unogaltheme.cxx Wed Oct 12 19:03:14 2011
@@ -36,6 +36,9 @@
 #include "svx/gallery1.hxx"
 #include "svx/galmisc.hxx"
 #include <svx/fmmodel.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/unopage.hxx>
+#include <svl/itempool.hxx>
 #include <rtl/uuid.h>
 #include <vos/mutex.hxx>
 #ifndef _SV_SVAPP_HXX_
@@ -313,23 +316,51 @@ void SAL_CALL GalleryTheme::update(  )
 	const uno::Reference< lang::XComponent >& Drawing, sal_Int32 nIndex )
 	throw (lang::WrappedTargetException, uno::RuntimeException)
 {
-	const ::vos::OGuard aGuard( Application::GetSolarMutex() );
-	sal_Int32 			nRet = -1;
-
-	if( mpTheme )
-	{
-		GalleryDrawingModel* pModel = GalleryDrawingModel::getImplementation( Drawing );
-
-		if( pModel && pModel->GetDoc() && pModel->GetDoc()->ISA( FmFormModel
) )
-		{
-			nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) );
+    const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+    sal_Int32           nRet = -1;
 
-			if( mpTheme->InsertModel( *static_cast< FmFormModel* >( pModel->GetDoc() ),
nIndex ) )
-				nRet = nIndex;
-		}
-	}
+    if( mpTheme )
+    {
+        GalleryDrawingModel* pModel = GalleryDrawingModel::getImplementation( Drawing );
+
+        if( pModel && pModel->GetDoc() && pModel->GetDoc()->ISA(
FmFormModel ) )
+        {
+            nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) );
+
+            if( mpTheme->InsertModel( *static_cast< FmFormModel* >( pModel->GetDoc()
), nIndex ) )
+                nRet = nIndex;
+        }
+        else if (!pModel)
+        {
+            try
+            {
+                uno::Reference< drawing::XDrawPagesSupplier > xDrawPagesSupplier( Drawing,
uno::UNO_QUERY_THROW );
+                uno::Reference< drawing::XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(),
uno::UNO_QUERY_THROW );
+                uno::Reference< drawing::XDrawPage > xPage( xDrawPages->getByIndex(
0 ), uno::UNO_QUERY_THROW );
+                SvxDrawPage* pUnoPage = xPage.is() ? SvxDrawPage::getImplementation( xPage
) : NULL;
+                SdrModel* pOrigModel = pUnoPage ? pUnoPage->GetSdrPage()->GetModel()
: NULL;
+                SdrPage* pOrigPage = pUnoPage ? pUnoPage->GetSdrPage() : NULL;
+
+                if (pOrigPage && pOrigModel)
+                {
+                    FmFormModel* pTmpModel = new FmFormModel(&pOrigModel->GetItemPool());
+                    SdrPage* pNewPage = pOrigPage->Clone();
+                    pTmpModel->InsertPage(pNewPage, 0);
+
+                    uno::Reference< lang::XComponent > xDrawing( new GalleryDrawingModel(
pTmpModel ) );
+                    pTmpModel->setUnoModel( uno::Reference< uno::XInterface >::query(
xDrawing ) );
+
+                    nRet = insertDrawingByIndex( xDrawing, nIndex );
+                    return nRet;
+                }
+            }
+            catch (...)
+            {
+            }
+        }
+    }
 
-	return nRet;
+    return nRet;
 }
 
 // ------------------------------------------------------------------------------



Mime
View raw message