summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2010-10-22 16:07:22 +0100
committerCaolán McNamara <caolanm@redhat.com>2010-10-22 16:07:22 +0100
commit58587a2508576f70e64e6a7a8990bb9915f4a69d (patch)
treeeb5d7fee659d90a2e2319e1e5a6f08bfb2f5e4eb /svx/source
parentd4cb36a04eeb015ad1aef7fb4218aad4ab1d3fa8 (diff)
#i80184# Allow adding drawing documents to gallery via API
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/unogallery/unogaltheme.cxx37
1 files changed, 36 insertions, 1 deletions
diff --git a/svx/source/unogallery/unogaltheme.cxx b/svx/source/unogallery/unogaltheme.cxx
index ba5fc799c6..d34f57b294 100644
--- a/svx/source/unogallery/unogaltheme.cxx
+++ b/svx/source/unogallery/unogaltheme.cxx
@@ -37,6 +37,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>
#include <vcl/svapp.hxx>
@@ -313,7 +316,7 @@ void SAL_CALL GalleryTheme::update( )
throw (lang::WrappedTargetException, uno::RuntimeException)
{
const ::vos::OGuard aGuard( Application::GetSolarMutex() );
- sal_Int32 nRet = -1;
+ sal_Int32 nRet = -1;
if( mpTheme )
{
@@ -321,11 +324,43 @@ void SAL_CALL GalleryTheme::update( )
if( pModel && pModel->GetDoc() && pModel->GetDoc()->ISA( FmFormModel ) )
{
+ //Here we're inserting something that's already a gallery theme drawing
+
nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) );
if( mpTheme->InsertModel( *static_cast< FmFormModel* >( pModel->GetDoc() ), nIndex ) )
nRet = nIndex;
}
+ else if (!pModel)
+ {
+ //#i80184# Try to do the right thing and make a Gallery drawing out of an ordinary
+ //Drawing if possible.
+ 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;