View | Details | Raw Unified | Return to issue 80184
Collapse All | Expand All

(-)svx.orig/source/unogallery/unogaltheme.cxx (-15 / +46 lines)
Lines 36-41 Link Here
36
#include "svx/gallery1.hxx"
36
#include "svx/gallery1.hxx"
37
#include "svx/galmisc.hxx"
37
#include "svx/galmisc.hxx"
38
#include <svx/fmmodel.hxx>
38
#include <svx/fmmodel.hxx>
39
#include <svx/svdpage.hxx>
40
#include <svx/unopage.hxx>
41
#include <svl/itempool.hxx>
39
#include <rtl/uuid.h>
42
#include <rtl/uuid.h>
40
#include <vos/mutex.hxx>
43
#include <vos/mutex.hxx>
41
#ifndef _SV_SVAPP_HXX_
44
#ifndef _SV_SVAPP_HXX_
Lines 313-335 Link Here
313
	const uno::Reference< lang::XComponent >& Drawing, sal_Int32 nIndex )
318
	const uno::Reference< lang::XComponent >& Drawing, sal_Int32 nIndex )
314
	throw (lang::WrappedTargetException, uno::RuntimeException)
319
	throw (lang::WrappedTargetException, uno::RuntimeException)
315
{
320
{
316
	const ::vos::OGuard aGuard( Application::GetSolarMutex() );
321
    const ::vos::OGuard aGuard( Application::GetSolarMutex() );
317
	sal_Int32 			nRet = -1;
322
    sal_Int32           nRet = -1;
318
323
319
	if( mpTheme )
324
    if( mpTheme )
320
	{
325
    {
321
		GalleryDrawingModel* pModel = GalleryDrawingModel::getImplementation( Drawing );
326
        GalleryDrawingModel* pModel = GalleryDrawingModel::getImplementation( Drawing );
327
328
        if( pModel && pModel->GetDoc() && pModel->GetDoc()->ISA( FmFormModel ) )
329
        {
330
            nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) );
331
332
            if( mpTheme->InsertModel( *static_cast< FmFormModel* >( pModel->GetDoc() ), nIndex ) )
333
                nRet = nIndex;
334
        }
335
        else if (!pModel)
336
        {
337
            try
338
            {
339
                uno::Reference< drawing::XDrawPagesSupplier > xDrawPagesSupplier( Drawing, uno::UNO_QUERY_THROW );
340
                uno::Reference< drawing::XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), uno::UNO_QUERY_THROW );
341
                uno::Reference< drawing::XDrawPage > xPage( xDrawPages->getByIndex( 0 ), uno::UNO_QUERY_THROW );
342
                SvxDrawPage* pUnoPage = xPage.is() ? SvxDrawPage::getImplementation( xPage ) : NULL;
343
                SdrModel* pOrigModel = pUnoPage ? pUnoPage->GetSdrPage()->GetModel() : NULL;
344
                SdrPage* pOrigPage = pUnoPage ? pUnoPage->GetSdrPage() : NULL;
345
346
                if (pOrigPage && pOrigModel)
347
                {
348
                    FmFormModel* pTmpModel = new FmFormModel(&pOrigModel->GetItemPool());
349
                    SdrPage* pNewPage = pOrigPage->Clone();
350
                    pTmpModel->InsertPage(pNewPage, 0);
351
352
                    uno::Reference< lang::XComponent > xDrawing( new GalleryDrawingModel( pTmpModel ) );
353
                    pTmpModel->setUnoModel( uno::Reference< uno::XInterface >::query( xDrawing ) );
354
355
                    nRet = insertDrawingByIndex( xDrawing, nIndex );
356
                    return nRet;
357
                }
358
            }
359
            catch (...)
360
            {
361
            }
362
        }
363
    }
322
364
323
		if( pModel && pModel->GetDoc() && pModel->GetDoc()->ISA( FmFormModel ) )
365
    return nRet;
324
		{
325
			nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) );
326
327
			if( mpTheme->InsertModel( *static_cast< FmFormModel* >( pModel->GetDoc() ), nIndex ) )
328
				nRet = nIndex;
329
		}
330
	}
331
332
	return nRet;
333
}
366
}
334
367
335
// ------------------------------------------------------------------------------
368
// ------------------------------------------------------------------------------

Return to issue 80184