2010-10-12 15:51:52 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-27 16:10:40 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2004-11-26 18:53:33 +00:00
|
|
|
|
2006-09-16 17:28:30 +00:00
|
|
|
|
2012-11-08 14:53:57 +02:00
|
|
|
#include <com/sun/star/i18n/Collator.hpp>
|
2004-11-26 18:53:33 +00:00
|
|
|
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <vcl/tabctrl.hxx>
|
|
|
|
#include <vcl/tabpage.hxx>
|
|
|
|
|
|
|
|
#include <vcl/button.hxx>
|
|
|
|
#include <vcl/fixed.hxx>
|
|
|
|
#include <vcl/lstbox.hxx>
|
|
|
|
#include <vcl/combobox.hxx>
|
|
|
|
|
2007-07-06 12:10:37 +00:00
|
|
|
#include <svx/svdetc.hxx>
|
|
|
|
#include <svx/svdstr.hrc>
|
2004-11-26 18:53:33 +00:00
|
|
|
#include "sdresid.hxx"
|
2009-10-06 07:38:24 +02:00
|
|
|
#include <unotools/viewoptions.hxx>
|
2004-11-26 18:53:33 +00:00
|
|
|
#include <com/sun/star/presentation/EffectNodeType.hpp>
|
|
|
|
#include "CustomAnimationCreateDialog.hxx"
|
|
|
|
#include "CustomAnimationCreateDialog.hrc"
|
|
|
|
#include "CustomAnimation.hrc"
|
|
|
|
#include "CustomAnimationPane.hxx"
|
2005-01-21 17:18:00 +00:00
|
|
|
#include "optsitem.hxx"
|
|
|
|
#include "sddll.hxx"
|
2012-02-08 01:49:36 +09:00
|
|
|
#include "sdmod.hxx"
|
2004-11-26 18:53:33 +00:00
|
|
|
|
2005-03-08 13:41:15 +00:00
|
|
|
#include "helpids.h"
|
|
|
|
|
2004-11-26 18:53:33 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
using ::com::sun::star::uno::UNO_QUERY;
|
|
|
|
using ::com::sun::star::uno::UNO_QUERY_THROW;
|
|
|
|
using ::com::sun::star::uno::Any;
|
|
|
|
using ::com::sun::star::uno::Reference;
|
|
|
|
using ::com::sun::star::uno::Exception;
|
|
|
|
|
|
|
|
using namespace ::com::sun::star::presentation;
|
|
|
|
|
|
|
|
namespace sd {
|
|
|
|
|
|
|
|
|
2007-07-06 12:10:37 +00:00
|
|
|
const int ENTRANCE = 0;
|
|
|
|
const int EMPHASIS = 1;
|
|
|
|
const int EXIT = 2;
|
|
|
|
const int MOTIONPATH = 3;
|
2009-01-06 08:40:41 +00:00
|
|
|
const int MISCEFFECTS = 4;
|
2007-07-06 12:10:37 +00:00
|
|
|
|
2004-11-26 18:53:33 +00:00
|
|
|
extern void fillDurationComboBox( ComboBox* pBox );
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
class CategoryListBox : public ListBox
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CategoryListBox( Window* pParent, const ResId& rResId );
|
|
|
|
~CategoryListBox();
|
|
|
|
|
2007-08-01 10:08:09 +00:00
|
|
|
virtual void MouseButtonUp( const MouseEvent& rMEvt );
|
|
|
|
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_uInt16 InsertCategory( const XubString& rStr, sal_uInt16 nPos = LISTBOX_APPEND );
|
2004-11-26 18:53:33 +00:00
|
|
|
|
2007-08-01 10:08:09 +00:00
|
|
|
void SetDoubleClickLink( const Link& rDoubleClickHdl ) { maDoubleClickHdl = rDoubleClickHdl; }
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
DECL_LINK(implDoubleClickHdl, void *);
|
2007-08-01 10:08:09 +00:00
|
|
|
|
2004-11-26 18:53:33 +00:00
|
|
|
private:
|
|
|
|
virtual void UserDraw( const UserDrawEvent& rUDEvt );
|
2007-08-01 10:08:09 +00:00
|
|
|
|
|
|
|
Link maDoubleClickHdl;
|
2004-11-26 18:53:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
CategoryListBox::CategoryListBox( Window* pParent, const ResId& rResId )
|
|
|
|
: ListBox( pParent, rResId )
|
|
|
|
{
|
2011-01-17 11:41:00 +01:00
|
|
|
EnableUserDraw( sal_True );
|
2007-08-01 10:08:09 +00:00
|
|
|
SetDoubleClickHdl( LINK( this, CategoryListBox, implDoubleClickHdl ) );
|
2004-11-26 18:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CategoryListBox::~CategoryListBox()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_uInt16 CategoryListBox::InsertCategory( const XubString& rStr, sal_uInt16 nPos /* = LISTBOX_APPEND */ )
|
2004-11-26 18:53:33 +00:00
|
|
|
{
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_uInt16 n = ListBox::InsertEntry( rStr, nPos );
|
2004-11-26 18:53:33 +00:00
|
|
|
if( n != LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
ListBox::SetEntryFlags( n, ListBox::GetEntryFlags(n) | LISTBOX_ENTRY_FLAG_DISABLE_SELECTION );
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CategoryListBox::UserDraw( const UserDrawEvent& rUDEvt )
|
|
|
|
{
|
2011-01-17 11:41:00 +01:00
|
|
|
const sal_uInt16 nItem = rUDEvt.GetItemId();
|
2004-11-26 18:53:33 +00:00
|
|
|
|
|
|
|
if( ListBox::GetEntryFlags(nItem) & LISTBOX_ENTRY_FLAG_DISABLE_SELECTION )
|
|
|
|
{
|
|
|
|
Rectangle aOutRect( rUDEvt.GetRect() );
|
|
|
|
OutputDevice* pDev = rUDEvt.GetDevice();
|
|
|
|
|
|
|
|
// fill the background
|
|
|
|
Color aColor (GetSettings().GetStyleSettings().GetDialogColor());
|
|
|
|
|
|
|
|
pDev->SetFillColor (aColor);
|
|
|
|
pDev->SetLineColor ();
|
|
|
|
pDev->DrawRect(aOutRect);
|
|
|
|
|
|
|
|
// Erase the four corner pixels to make the rectangle appear rounded.
|
|
|
|
pDev->SetLineColor( GetSettings().GetStyleSettings().GetWindowColor());
|
|
|
|
pDev->DrawPixel( aOutRect.TopLeft());
|
|
|
|
pDev->DrawPixel( Point(aOutRect.Right(), aOutRect.Top()));
|
|
|
|
pDev->DrawPixel( Point(aOutRect.Left(), aOutRect.Bottom()));
|
|
|
|
pDev->DrawPixel( Point(aOutRect.Right(), aOutRect.Bottom()));
|
|
|
|
|
|
|
|
// draw the category title
|
|
|
|
pDev->DrawText (aOutRect, GetEntry(nItem), TEXT_DRAW_CENTER );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-17 11:41:00 +01:00
|
|
|
DrawEntry( rUDEvt, sal_True, sal_True );
|
2004-11-26 18:53:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(CategoryListBox, implDoubleClickHdl)
|
2007-08-01 10:08:09 +00:00
|
|
|
{
|
|
|
|
CaptureMouse();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CategoryListBox::MouseButtonUp( const MouseEvent& rMEvt )
|
|
|
|
{
|
2009-05-07 12:38:03 +00:00
|
|
|
ReleaseMouse();
|
2007-08-01 10:08:09 +00:00
|
|
|
if( rMEvt.IsLeft() && (rMEvt.GetClicks() == 2) )
|
|
|
|
{
|
|
|
|
if( maDoubleClickHdl.IsSet() )
|
|
|
|
maDoubleClickHdl.Call( this );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-05-07 12:38:03 +00:00
|
|
|
ListBox::MouseButtonUp( rMEvt );
|
2007-08-01 10:08:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
2004-11-26 18:53:33 +00:00
|
|
|
class CustomAnimationCreateTabPage : public TabPage
|
|
|
|
{
|
|
|
|
public:
|
2007-07-06 12:10:37 +00:00
|
|
|
CustomAnimationCreateTabPage( Window* pParent, CustomAnimationCreateDialog* pDialogParent, int nTabId, const PresetCategoryList& rCategoryList, bool bHasText );
|
2004-11-26 18:53:33 +00:00
|
|
|
~CustomAnimationCreateTabPage();
|
|
|
|
|
2007-07-06 12:10:37 +00:00
|
|
|
PathKind getCreatePathKind() const;
|
2004-11-26 18:53:33 +00:00
|
|
|
CustomAnimationPresetPtr getSelectedPreset() const;
|
|
|
|
double getDuration() const;
|
|
|
|
void setDuration( double fDuration );
|
|
|
|
|
|
|
|
bool getIsPreview() const;
|
|
|
|
void setIsPreview( bool bIsPreview );
|
|
|
|
|
2008-04-02 08:43:35 +00:00
|
|
|
bool select( const OUString& rsPresetId );
|
|
|
|
|
2004-11-26 18:53:33 +00:00
|
|
|
private:
|
|
|
|
DECL_LINK( implSelectHdl, Control* );
|
|
|
|
DECL_LINK( implDoubleClickHdl, Control* );
|
|
|
|
|
|
|
|
void onSelectEffect();
|
|
|
|
|
|
|
|
void clearEffects();
|
|
|
|
|
|
|
|
private:
|
|
|
|
CategoryListBox* mpLBEffects;
|
|
|
|
FixedText* mpFTSpeed;
|
|
|
|
ComboBox* mpCBSpeed;
|
|
|
|
CheckBox* mpCBXPReview;
|
|
|
|
|
|
|
|
CustomAnimationCreateDialog* mpParent;
|
2007-07-06 12:10:37 +00:00
|
|
|
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_uInt16 mnCurvePathPos;
|
|
|
|
sal_uInt16 mnPolygonPathPos;
|
|
|
|
sal_uInt16 mnFreeformPathPos;
|
2007-08-01 10:08:09 +00:00
|
|
|
|
2004-11-26 18:53:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ImplStlEffectCategorySortHelper
|
|
|
|
{
|
|
|
|
ImplStlEffectCategorySortHelper();
|
|
|
|
bool operator()( const CustomAnimationPresetPtr& p1, const CustomAnimationPresetPtr& p2 );
|
|
|
|
|
|
|
|
private:
|
|
|
|
uno::Reference< i18n::XCollator > mxCollator;
|
|
|
|
};
|
|
|
|
|
|
|
|
ImplStlEffectCategorySortHelper::ImplStlEffectCategorySortHelper()
|
|
|
|
{
|
2012-11-08 14:53:57 +02:00
|
|
|
mxCollator = i18n::Collator::create( ::comphelper::getProcessComponentContext() );
|
2004-11-26 18:53:33 +00:00
|
|
|
|
2012-11-08 14:53:57 +02:00
|
|
|
const lang::Locale& rLocale = Application::GetSettings().GetLanguageTag().getLocale();
|
|
|
|
mxCollator->loadDefaultCollator(rLocale, 0);
|
2004-11-26 18:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ImplStlEffectCategorySortHelper::operator()( const CustomAnimationPresetPtr& p1, const CustomAnimationPresetPtr& p2 )
|
|
|
|
{
|
2012-11-08 14:53:57 +02:00
|
|
|
return mxCollator->compareString(p1->getLabel(), p2->getLabel()) == -1;
|
2004-11-26 18:53:33 +00:00
|
|
|
}
|
|
|
|
|
2007-07-06 12:10:37 +00:00
|
|
|
CustomAnimationCreateTabPage::CustomAnimationCreateTabPage( Window* pParent, CustomAnimationCreateDialog* pDialogParent, int nTabId, const PresetCategoryList& rCategoryList, bool bHasText )
|
|
|
|
: TabPage( pParent, SdResId( RID_TP_CUSTOMANIMATION_ENTRANCE ) )
|
|
|
|
, mpParent( pDialogParent )
|
|
|
|
, mnCurvePathPos( LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
, mnPolygonPathPos( LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
, mnFreeformPathPos( LISTBOX_ENTRY_NOTFOUND )
|
2004-11-26 18:53:33 +00:00
|
|
|
{
|
|
|
|
mpLBEffects = new CategoryListBox( this, SdResId( LB_EFFECTS ) );
|
|
|
|
mpFTSpeed = new FixedText( this, SdResId( FT_SPEED ) );
|
|
|
|
mpCBSpeed = new ComboBox( this, SdResId( CB_SPEED ) );
|
|
|
|
mpCBXPReview = new CheckBox( this, SdResId( CBX_PREVIEW ) );
|
|
|
|
|
2008-03-12 10:33:03 +00:00
|
|
|
String sMotionPathLabel( SdResId( STR_USERPATH ) );
|
|
|
|
|
2004-11-26 18:53:33 +00:00
|
|
|
FreeResource();
|
|
|
|
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_uInt16 nFirstEffect = LISTBOX_ENTRY_NOTFOUND;
|
2005-03-23 12:56:20 +00:00
|
|
|
|
2008-03-12 10:33:03 +00:00
|
|
|
if( nTabId == MOTIONPATH )
|
|
|
|
{
|
|
|
|
mpLBEffects->InsertCategory( sMotionPathLabel );
|
|
|
|
|
|
|
|
mnCurvePathPos = nFirstEffect = mpLBEffects->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulCOMBLINE) );
|
|
|
|
mnPolygonPathPos = mpLBEffects->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulPOLY) );
|
|
|
|
mnFreeformPathPos = mpLBEffects->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulFREELINE) );
|
|
|
|
};
|
2007-07-06 12:10:37 +00:00
|
|
|
|
2006-12-12 15:50:36 +00:00
|
|
|
PresetCategoryList::const_iterator aCategoryIter( rCategoryList.begin() );
|
|
|
|
const PresetCategoryList::const_iterator aCategoryEnd( rCategoryList.end() );
|
|
|
|
while( aCategoryIter != aCategoryEnd )
|
2004-11-26 18:53:33 +00:00
|
|
|
{
|
2006-12-12 15:50:36 +00:00
|
|
|
PresetCategoryPtr pCategory( *aCategoryIter++ );
|
2004-11-26 18:53:33 +00:00
|
|
|
if( pCategory.get() )
|
|
|
|
{
|
|
|
|
mpLBEffects->InsertCategory( pCategory->maLabel );
|
|
|
|
|
|
|
|
std::vector< CustomAnimationPresetPtr > aSortedVector(pCategory->maEffects.size());
|
|
|
|
std::copy( pCategory->maEffects.begin(), pCategory->maEffects.end(), aSortedVector.begin() );
|
|
|
|
ImplStlEffectCategorySortHelper aSortHelper;
|
|
|
|
std::sort( aSortedVector.begin(), aSortedVector.end(), aSortHelper );
|
|
|
|
|
|
|
|
std::vector< CustomAnimationPresetPtr >::const_iterator aIter( aSortedVector.begin() );
|
|
|
|
const std::vector< CustomAnimationPresetPtr >::const_iterator aEnd( aSortedVector.end() );
|
|
|
|
while( aIter != aEnd )
|
|
|
|
{
|
|
|
|
CustomAnimationPresetPtr pDescriptor = (*aIter++);
|
|
|
|
if( pDescriptor.get() && (bHasText || !pDescriptor->isTextOnly() ) )
|
|
|
|
{
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_uInt16 nPos = mpLBEffects->InsertEntry( pDescriptor->getLabel() );
|
2004-11-26 18:53:33 +00:00
|
|
|
mpLBEffects->SetEntryData( nPos, static_cast<void*>( new CustomAnimationPresetPtr( pDescriptor ) ) );
|
2005-03-23 12:56:20 +00:00
|
|
|
|
|
|
|
if( nFirstEffect == LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
nFirstEffect = nPos;
|
2004-11-26 18:53:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-23 12:56:20 +00:00
|
|
|
mpLBEffects->SelectEntryPos( nFirstEffect );
|
|
|
|
|
2004-11-26 18:53:33 +00:00
|
|
|
fillDurationComboBox( mpCBSpeed );
|
2005-05-20 11:00:55 +00:00
|
|
|
|
|
|
|
if( nFirstEffect != LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
onSelectEffect();
|
2004-11-26 18:53:33 +00:00
|
|
|
|
|
|
|
mpLBEffects->SetSelectHdl( LINK( this, CustomAnimationCreateTabPage, implSelectHdl ) );
|
2007-08-01 10:08:09 +00:00
|
|
|
mpLBEffects->SetDoubleClickLink( LINK( this, CustomAnimationCreateTabPage, implDoubleClickHdl ) );
|
2004-11-26 18:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CustomAnimationCreateTabPage::~CustomAnimationCreateTabPage()
|
|
|
|
{
|
|
|
|
clearEffects();
|
|
|
|
|
|
|
|
delete mpLBEffects;
|
|
|
|
delete mpFTSpeed;
|
|
|
|
delete mpCBSpeed;
|
|
|
|
delete mpCBXPReview;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( CustomAnimationCreateTabPage, implSelectHdl, Control*, pControl )
|
|
|
|
{
|
|
|
|
if( pControl == mpLBEffects )
|
|
|
|
onSelectEffect();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( CustomAnimationCreateTabPage, implDoubleClickHdl, Control*, pControl )
|
|
|
|
{
|
|
|
|
if( pControl == mpLBEffects )
|
|
|
|
{
|
|
|
|
if( mpLBEffects->GetSelectEntryCount() )
|
2011-01-17 11:41:00 +01:00
|
|
|
mpParent->EndDialog( sal_True );
|
2004-11-26 18:53:33 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomAnimationCreateTabPage::onSelectEffect()
|
|
|
|
{
|
|
|
|
CustomAnimationPresetPtr*p = static_cast< CustomAnimationPresetPtr* >( mpLBEffects->GetEntryData( mpLBEffects->GetSelectEntryPos() ) );
|
|
|
|
|
|
|
|
if( !p )
|
|
|
|
return;
|
|
|
|
|
|
|
|
CustomAnimationPresetPtr pPreset( *p );
|
|
|
|
|
|
|
|
const double fDuration = pPreset->getDuration();
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_uInt16 nPos = 0xffff;
|
2004-11-26 18:53:33 +00:00
|
|
|
|
|
|
|
if( fDuration == 5.0 )
|
|
|
|
nPos = 0;
|
|
|
|
else if( fDuration == 3.0 )
|
|
|
|
nPos = 1;
|
|
|
|
else if( fDuration == 2.0 )
|
|
|
|
nPos = 2;
|
|
|
|
else if( fDuration == 1.0 )
|
|
|
|
nPos = 3;
|
|
|
|
else if( fDuration == 0.5 )
|
|
|
|
nPos = 4;
|
|
|
|
|
|
|
|
mpCBSpeed->SelectEntryPos( nPos );
|
|
|
|
|
2005-05-20 11:00:55 +00:00
|
|
|
bool bHasSpeed = pPreset->getDuration() > 0.001;
|
|
|
|
mpCBSpeed->Enable( bHasSpeed );
|
|
|
|
mpFTSpeed->Enable( bHasSpeed );
|
|
|
|
|
2004-11-26 18:53:33 +00:00
|
|
|
if( mpCBXPReview->IsChecked() )
|
|
|
|
{
|
|
|
|
mpParent->preview( pPreset );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomAnimationCreateTabPage::clearEffects()
|
|
|
|
{
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_uInt16 nPos = mpLBEffects->GetEntryCount();
|
2004-11-26 18:53:33 +00:00
|
|
|
while( nPos-- )
|
|
|
|
delete static_cast< CustomAnimationPresetPtr* >( mpLBEffects->GetEntryData( nPos ) );
|
|
|
|
|
|
|
|
mpLBEffects->Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
CustomAnimationPresetPtr CustomAnimationCreateTabPage::getSelectedPreset() const
|
|
|
|
{
|
|
|
|
CustomAnimationPresetPtr pPreset;
|
|
|
|
|
|
|
|
if( mpLBEffects->GetSelectEntryCount() == 1 )
|
2007-07-06 12:10:37 +00:00
|
|
|
{
|
|
|
|
void* pEntryData = mpLBEffects->GetEntryData( mpLBEffects->GetSelectEntryPos() );
|
|
|
|
if( pEntryData )
|
|
|
|
pPreset = *static_cast< CustomAnimationPresetPtr* >( pEntryData );
|
|
|
|
}
|
2004-11-26 18:53:33 +00:00
|
|
|
|
|
|
|
return pPreset;
|
|
|
|
}
|
|
|
|
|
2007-07-06 12:10:37 +00:00
|
|
|
PathKind CustomAnimationCreateTabPage::getCreatePathKind() const
|
|
|
|
{
|
|
|
|
PathKind eKind = NONE;
|
|
|
|
|
|
|
|
if( mpLBEffects->GetSelectEntryCount() == 1 )
|
|
|
|
{
|
2011-01-17 11:41:00 +01:00
|
|
|
const sal_uInt16 nPos = mpLBEffects->GetSelectEntryPos();
|
2007-07-06 12:10:37 +00:00
|
|
|
if( nPos == mnCurvePathPos )
|
|
|
|
{
|
|
|
|
eKind = CURVE;
|
|
|
|
}
|
|
|
|
else if( nPos == mnPolygonPathPos )
|
|
|
|
{
|
|
|
|
eKind = POLYGON;
|
|
|
|
}
|
|
|
|
else if( nPos == mnFreeformPathPos )
|
|
|
|
{
|
|
|
|
eKind = FREEFORM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return eKind;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-11-26 18:53:33 +00:00
|
|
|
double CustomAnimationCreateTabPage::getDuration() const
|
|
|
|
{
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_uInt16 nPos = mpCBSpeed->GetSelectEntryPos();
|
2005-05-20 11:00:55 +00:00
|
|
|
if( (nPos == 0xffff) || !mpCBSpeed->IsEnabled() )
|
2004-11-26 18:53:33 +00:00
|
|
|
{
|
|
|
|
CustomAnimationPresetPtr pPreset = getSelectedPreset();
|
|
|
|
if( pPreset.get() )
|
|
|
|
return pPreset->getDuration();
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( nPos )
|
|
|
|
{
|
|
|
|
case 0: return 5.0f;
|
|
|
|
case 1: return 3.0f;
|
|
|
|
case 2: return 2.0f;
|
|
|
|
case 3: return 1.0f;
|
|
|
|
case 4: return 0.5f;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomAnimationCreateTabPage::setDuration( double fDuration )
|
|
|
|
{
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_uInt16 nPos = 0;
|
2004-11-26 18:53:33 +00:00
|
|
|
if( fDuration < 2.0f )
|
|
|
|
{
|
|
|
|
if( fDuration < 1.0f )
|
|
|
|
{
|
|
|
|
nPos = 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nPos = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( fDuration < 5.0f )
|
|
|
|
{
|
|
|
|
if( fDuration < 3.0f )
|
|
|
|
{
|
|
|
|
nPos = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nPos = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mpCBSpeed->SelectEntryPos( nPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CustomAnimationCreateTabPage::getIsPreview() const
|
|
|
|
{
|
|
|
|
return mpCBXPReview->IsChecked() ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomAnimationCreateTabPage::setIsPreview( bool bIsPreview )
|
|
|
|
{
|
2011-01-17 11:41:00 +01:00
|
|
|
mpCBXPReview->Check( bIsPreview ? sal_True : sal_False );
|
2004-11-26 18:53:33 +00:00
|
|
|
}
|
|
|
|
|
2008-04-02 08:43:35 +00:00
|
|
|
bool CustomAnimationCreateTabPage::select( const OUString& rsPresetId )
|
|
|
|
{
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_uInt16 nPos = mpLBEffects->GetEntryCount();
|
2008-04-02 08:43:35 +00:00
|
|
|
while( nPos-- )
|
|
|
|
{
|
|
|
|
void* pEntryData = mpLBEffects->GetEntryData( nPos );
|
|
|
|
if( pEntryData )
|
|
|
|
{
|
|
|
|
CustomAnimationPresetPtr& pPtr = *static_cast< CustomAnimationPresetPtr* >(pEntryData);
|
|
|
|
if( pPtr.get() && pPtr->getPresetId() == rsPresetId )
|
|
|
|
{
|
|
|
|
mpLBEffects->SelectEntryPos( nPos );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-11-26 18:53:33 +00:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
CustomAnimationCreateDialog::CustomAnimationCreateDialog( Window* pParent, CustomAnimationPane* pPane, const std::vector< ::com::sun::star::uno::Any >& rTargets, bool bHasText, const OUString& rsPresetId, double fDuration )
|
2008-04-02 08:43:35 +00:00
|
|
|
: TabDialog( pParent, SdResId( DLG_CUSTOMANIMATION_CREATE ) )
|
|
|
|
, mpPane( pPane )
|
|
|
|
, mrTargets( rTargets )
|
|
|
|
, mfDuration( fDuration )
|
2004-11-26 18:53:33 +00:00
|
|
|
{
|
|
|
|
mpTabControl = new TabControl( this, SdResId( 1 ) );
|
|
|
|
mpOKButton = new OKButton(this, SdResId( 1 ) ) ;
|
|
|
|
mpCancelButton = new CancelButton(this, SdResId( 1 ) );
|
|
|
|
mpHelpButton = new HelpButton(this, SdResId( 1 ) );
|
|
|
|
|
|
|
|
FreeResource();
|
|
|
|
|
2005-01-21 17:18:00 +00:00
|
|
|
SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
|
|
|
|
mbIsPreview = pOptions->IsPreviewNewEffects();
|
|
|
|
|
2004-11-26 18:53:33 +00:00
|
|
|
const CustomAnimationPresets& rPresets = CustomAnimationPresets::getCustomAnimationPresets();
|
2007-07-06 12:10:37 +00:00
|
|
|
mpTabPages[ENTRANCE] = new CustomAnimationCreateTabPage( mpTabControl, this, ENTRANCE, rPresets.getEntrancePresets(), bHasText );
|
2005-03-08 13:41:15 +00:00
|
|
|
mpTabPages[ENTRANCE]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_ENTRANCE );
|
2004-11-26 18:53:33 +00:00
|
|
|
mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_ENTRANCE, mpTabPages[ENTRANCE] );
|
2007-07-06 12:10:37 +00:00
|
|
|
mpTabPages[EMPHASIS] = new CustomAnimationCreateTabPage( mpTabControl, this, EMPHASIS, rPresets.getEmphasisPresets(), bHasText );
|
2005-03-08 13:41:15 +00:00
|
|
|
mpTabPages[EMPHASIS]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_EMPHASIS );
|
2004-11-26 18:53:33 +00:00
|
|
|
mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_EMPHASIS, mpTabPages[EMPHASIS] );
|
2007-07-06 12:10:37 +00:00
|
|
|
mpTabPages[EXIT] = new CustomAnimationCreateTabPage( mpTabControl, this, EXIT, rPresets.getExitPresets(), bHasText );
|
2005-03-08 13:41:15 +00:00
|
|
|
mpTabPages[EXIT]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_EXIT );
|
2004-11-26 18:53:33 +00:00
|
|
|
mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_EXIT, mpTabPages[EXIT] );
|
2007-07-06 12:10:37 +00:00
|
|
|
mpTabPages[MOTIONPATH] = new CustomAnimationCreateTabPage( mpTabControl, this, MOTIONPATH, rPresets.getMotionPathsPresets(), bHasText );
|
2005-03-08 13:41:15 +00:00
|
|
|
mpTabPages[MOTIONPATH]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_MOTIONPATH );
|
2004-11-26 18:53:33 +00:00
|
|
|
mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_MOTIONPATH, mpTabPages[MOTIONPATH] );
|
2009-01-06 08:40:41 +00:00
|
|
|
mpTabPages[MISCEFFECTS] = new CustomAnimationCreateTabPage( mpTabControl, this, MISCEFFECTS, rPresets.getMiscPresets(), bHasText );
|
|
|
|
mpTabPages[MISCEFFECTS]->SetHelpId( HID_SD_CUSTOMANIMATIONDIALOG_MISCEFFECTS );
|
|
|
|
mpTabControl->SetTabPage( RID_TP_CUSTOMANIMATION_MISCEFFECTS, mpTabPages[MISCEFFECTS] );
|
2004-11-26 18:53:33 +00:00
|
|
|
|
2005-01-21 17:18:00 +00:00
|
|
|
getCurrentPage()->setDuration( mfDuration );
|
|
|
|
getCurrentPage()->setIsPreview( mbIsPreview );
|
|
|
|
|
2004-11-26 18:53:33 +00:00
|
|
|
mpTabControl->SetActivatePageHdl( LINK( this, CustomAnimationCreateDialog, implActivatePagekHdl ) );
|
|
|
|
mpTabControl->SetDeactivatePageHdl( LINK( this, CustomAnimationCreateDialog, implDeactivatePagekHdl ) );
|
|
|
|
|
2005-03-23 12:56:20 +00:00
|
|
|
setPosition();
|
2008-04-02 08:43:35 +00:00
|
|
|
|
|
|
|
// select current preset if available
|
2012-01-08 09:52:25 -02:00
|
|
|
if( !rsPresetId.isEmpty() )
|
2008-04-02 08:43:35 +00:00
|
|
|
{
|
|
|
|
for( sal_uInt16 i = ENTRANCE; i <= MOTIONPATH; i++ )
|
|
|
|
{
|
|
|
|
if( mpTabPages[i]->select( rsPresetId ) )
|
|
|
|
{
|
|
|
|
mpTabControl->SetCurPageId( RID_TP_CUSTOMANIMATION_ENTRANCE + i );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-11-26 18:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CustomAnimationCreateDialog::~CustomAnimationCreateDialog()
|
|
|
|
{
|
2005-03-23 12:56:20 +00:00
|
|
|
storePosition();
|
|
|
|
|
2005-01-21 17:18:00 +00:00
|
|
|
SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
|
|
|
|
pOptions->SetPreviewNewEffects( getCurrentPage()->getIsPreview() );
|
|
|
|
|
2004-11-26 18:53:33 +00:00
|
|
|
delete mpTabPages[ENTRANCE];
|
|
|
|
delete mpTabPages[EMPHASIS];
|
|
|
|
delete mpTabPages[EXIT];
|
|
|
|
delete mpTabPages[MOTIONPATH];
|
2009-01-06 08:40:41 +00:00
|
|
|
delete mpTabPages[MISCEFFECTS];
|
2004-11-26 18:53:33 +00:00
|
|
|
|
|
|
|
delete mpTabControl;
|
|
|
|
delete mpOKButton;
|
|
|
|
delete mpCancelButton;
|
|
|
|
delete mpHelpButton;
|
|
|
|
}
|
|
|
|
|
|
|
|
CustomAnimationCreateTabPage* CustomAnimationCreateDialog::getCurrentPage() const
|
|
|
|
{
|
|
|
|
switch( mpTabControl->GetCurPageId() )
|
|
|
|
{
|
|
|
|
case RID_TP_CUSTOMANIMATION_ENTRANCE: return mpTabPages[ENTRANCE];
|
|
|
|
case RID_TP_CUSTOMANIMATION_EMPHASIS: return mpTabPages[EMPHASIS];
|
|
|
|
case RID_TP_CUSTOMANIMATION_EXIT: return mpTabPages[EXIT];
|
2009-01-06 08:40:41 +00:00
|
|
|
case RID_TP_CUSTOMANIMATION_MISCEFFECTS:return mpTabPages[MISCEFFECTS];
|
2004-11-26 18:53:33 +00:00
|
|
|
default:
|
|
|
|
return mpTabPages[MOTIONPATH];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-06 12:10:37 +00:00
|
|
|
PathKind CustomAnimationCreateDialog::getCreatePathKind() const
|
|
|
|
{
|
|
|
|
return getCurrentPage()->getCreatePathKind();
|
|
|
|
}
|
|
|
|
|
2004-11-26 18:53:33 +00:00
|
|
|
CustomAnimationPresetPtr CustomAnimationCreateDialog::getSelectedPreset() const
|
|
|
|
{
|
|
|
|
return getCurrentPage()->getSelectedPreset();
|
|
|
|
}
|
|
|
|
|
|
|
|
double CustomAnimationCreateDialog::getSelectedDuration() const
|
|
|
|
{
|
|
|
|
return getCurrentPage()->getDuration();
|
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(CustomAnimationCreateDialog, implActivatePagekHdl)
|
2004-11-26 18:53:33 +00:00
|
|
|
{
|
|
|
|
getCurrentPage()->setDuration( mfDuration );
|
|
|
|
getCurrentPage()->setIsPreview( mbIsPreview );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(CustomAnimationCreateDialog, implDeactivatePagekHdl)
|
2004-11-26 18:53:33 +00:00
|
|
|
{
|
|
|
|
mfDuration = getCurrentPage()->getDuration();
|
|
|
|
mbIsPreview = getCurrentPage()->getIsPreview();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomAnimationCreateDialog::preview( const CustomAnimationPresetPtr& pPreset ) const
|
|
|
|
{
|
|
|
|
MainSequencePtr pSequence( new MainSequence() );
|
|
|
|
|
|
|
|
std::vector< Any >::const_iterator aIter( mrTargets.begin() );
|
|
|
|
const std::vector< Any >::const_iterator aEnd( mrTargets.end() );
|
|
|
|
|
|
|
|
const double fDuration = getSelectedDuration();
|
|
|
|
|
|
|
|
bool bFirst = true;
|
|
|
|
while( aIter != aEnd )
|
|
|
|
{
|
|
|
|
CustomAnimationEffectPtr pNew(
|
|
|
|
pSequence->append( pPreset, (*aIter++), fDuration ) );
|
|
|
|
|
|
|
|
if( bFirst )
|
|
|
|
bFirst = false;
|
|
|
|
else
|
|
|
|
pNew->setNodeType( EffectNodeType::WITH_PREVIOUS );
|
|
|
|
}
|
|
|
|
|
|
|
|
mpPane->preview( pSequence->getRootNode() );
|
|
|
|
}
|
|
|
|
|
2005-03-23 12:56:20 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
Window * lcl_GetTopmostParent( Window * pWindow )
|
|
|
|
{
|
|
|
|
Window * pResult = 0;
|
|
|
|
Window * pCurrent = pWindow ? pWindow->GetParent() : 0;
|
|
|
|
while( pCurrent )
|
|
|
|
{
|
|
|
|
pResult = pCurrent;
|
|
|
|
pCurrent = pCurrent->GetParent();
|
|
|
|
}
|
|
|
|
return pResult;
|
|
|
|
}
|
2004-11-26 18:53:33 +00:00
|
|
|
}
|
|
|
|
|
2005-03-23 12:56:20 +00:00
|
|
|
void CustomAnimationCreateDialog::setPosition()
|
|
|
|
{
|
|
|
|
SvtViewOptions aDlgOpt(
|
2013-01-20 13:55:09 +01:00
|
|
|
E_TABDIALOG, OUString::number(DLG_CUSTOMANIMATION_CREATE));
|
2005-03-23 12:56:20 +00:00
|
|
|
if ( aDlgOpt.Exists() )
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
SetWindowState( OUStringToOString(aDlgOpt.GetWindowState(),
|
2011-09-07 22:41:13 +01:00
|
|
|
RTL_TEXTENCODING_ASCII_US) );
|
2005-03-23 12:56:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// default position: aligned with right edge of parent
|
|
|
|
Window * pParent = lcl_GetTopmostParent( this );
|
|
|
|
if( pParent )
|
|
|
|
{
|
|
|
|
Point aPos( GetPosPixel());
|
|
|
|
Size aSize( GetSizePixel());
|
|
|
|
Size aParentSize( pParent->GetSizePixel());
|
|
|
|
|
|
|
|
// right center
|
|
|
|
aPos.setX( aParentSize.getWidth() - aSize.getWidth() );
|
|
|
|
aPos.setY( (aParentSize.getHeight() - aSize.getHeight()) / 2 );
|
|
|
|
SetPosPixel( aPos );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomAnimationCreateDialog::storePosition()
|
|
|
|
{
|
|
|
|
// save settings (screen position and current page)
|
|
|
|
SvtViewOptions aDlgOpt(
|
2013-01-20 13:55:09 +01:00
|
|
|
E_TABDIALOG, OUString::number(DLG_CUSTOMANIMATION_CREATE));
|
2011-06-22 00:50:05 +01:00
|
|
|
aDlgOpt.SetWindowState(OStringToOUString(
|
|
|
|
GetWindowState(WINDOWSTATE_MASK_POS), RTL_TEXTENCODING_ASCII_US));
|
2005-03-23 12:56:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2010-10-12 15:51:52 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|