LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - animobjs.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 607 0.2 %
Date: 2015-06-13 12:38:46 Functions: 2 46 4.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/presentation/AnimationEffect.hpp>
      21             : #include <com/sun/star/presentation/AnimationSpeed.hpp>
      22             : #include <svx/xoutbmp.hxx>
      23             : #include <time.h>
      24             : #include <svl/eitem.hxx>
      25             : #include <svx/svdograf.hxx>
      26             : #include <svx/svdogrp.hxx>
      27             : #include <sfx2/basedlgs.hxx>
      28             : #include <sfx2/dispatch.hxx>
      29             : #include <sfx2/progress.hxx>
      30             : #include <vcl/msgbox.hxx>
      31             : 
      32             : #include "anminfo.hxx"
      33             : #include "animobjs.hxx"
      34             : #include "app.hrc"
      35             : #include "strings.hrc"
      36             : #include "sdresid.hxx"
      37             : #include "View.hxx"
      38             : #include "drawdoc.hxx"
      39             : #include "sdpage.hxx"
      40             : #include "res_bmp.hrc"
      41             : #include "ViewShell.hxx"
      42             : 
      43             : #include <vcl/svapp.hxx>
      44             : #include <vcl/settings.hxx>
      45             : 
      46             : #include <EffectMigration.hxx>
      47             : 
      48             : #include <string>
      49             : #include <algorithm>
      50             : 
      51             : using namespace ::com::sun::star;
      52             : 
      53             : namespace sd {
      54             : 
      55             : /**
      56             :  *  SdDisplay - Control
      57             :  */
      58           0 : SdDisplay::SdDisplay(vcl::Window* pWin)
      59             :     : Control(pWin, 0)
      60           0 :     , aScale(1, 1)
      61             : {
      62           0 :     SetMapMode( MAP_PIXEL );
      63           0 :     const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
      64           0 :     SetBackground( Wallpaper( Color( rStyles.GetFieldColor() ) ) );
      65           0 : }
      66             : 
      67           0 : SdDisplay::~SdDisplay()
      68             : {
      69           0 : }
      70             : 
      71           0 : void SdDisplay::SetBitmapEx( BitmapEx* pBmpEx )
      72             : {
      73           0 :     if( pBmpEx )
      74             :     {
      75           0 :         aBitmapEx = *pBmpEx;
      76             :     }
      77             :     else
      78             :     {
      79           0 :         const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
      80           0 :         const Color aFillColor = rStyles.GetFieldColor();
      81           0 :         aBitmapEx.Erase(aFillColor);
      82             :     }
      83           0 : }
      84             : 
      85           0 : void SdDisplay::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
      86             : {
      87           0 :     Point aPt;
      88           0 :     Size aSize = GetOutputSize();
      89           0 :     Size aBmpSize = aBitmapEx.GetBitmap().GetSizePixel();
      90           0 :     aBmpSize.Width() = (long) ( (double) aBmpSize.Width() * (double) aScale );
      91           0 :     aBmpSize.Height() = (long) ( (double) aBmpSize.Height() * (double) aScale );
      92             : 
      93           0 :     if( aBmpSize.Width() < aSize.Width() )
      94           0 :         aPt.X() = ( aSize.Width() - aBmpSize.Width() ) / 2;
      95           0 :     if( aBmpSize.Height() < aSize.Height() )
      96           0 :         aPt.Y() = ( aSize.Height() - aBmpSize.Height() ) / 2;
      97             : 
      98           0 :     aBitmapEx.Draw( this, aPt, aBmpSize );
      99           0 : }
     100             : 
     101           0 : void SdDisplay::SetScale( const Fraction& rFrac )
     102             : {
     103           0 :     aScale = rFrac;
     104           0 : }
     105             : 
     106           0 : Size SdDisplay::GetOptimalSize() const
     107             : {
     108           0 :     return LogicToPixel(Size(147, 87), MAP_APPFONT);
     109             : }
     110             : 
     111           0 : void SdDisplay::DataChanged( const DataChangedEvent& rDCEvt )
     112             : {
     113           0 :     Control::DataChanged( rDCEvt );
     114             : 
     115           0 :     if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
     116             :     {
     117           0 :         const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
     118           0 :         SetBackground( Wallpaper( Color( rStyles.GetFieldColor() ) ) );
     119           0 :         SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode()
     120             :             ? sd::OUTPUT_DRAWMODE_CONTRAST
     121           0 :             : sd::OUTPUT_DRAWMODE_COLOR );
     122             :     }
     123           0 : }
     124             : 
     125             : const size_t AnimationWindow::EMPTY_FRAMELIST = std::numeric_limits<size_t>::max();
     126             : 
     127             : /**
     128             :  *  AnimationWindow - FloatingWindow
     129             :  */
     130           0 : AnimationWindow::AnimationWindow(SfxBindings* pInBindings, SfxChildWindow *pCW, vcl::Window* pParent)
     131             :     : SfxDockingWindow(pInBindings, pCW, pParent,
     132             :         "DockingAnimation", "modules/simpress/ui/dockinganimation.ui")
     133             :     , pWin(pParent)
     134             :     , m_nCurrentFrame(EMPTY_FRAMELIST)
     135             :     , bMovie(false)
     136             :     , bAllObjects(false)
     137           0 :     , pBindings(pInBindings)
     138             : {
     139           0 :     get(m_pBtnFirst, "first");
     140           0 :     get(m_pBtnReverse, "prev");
     141           0 :     get(m_pBtnStop, "stop");
     142           0 :     get(m_pBtnPlay, "next");
     143           0 :     get(m_pBtnLast, "last");
     144           0 :     get(m_pNumFldBitmap, "numbitmap");
     145           0 :     get(m_pTimeField, "duration");
     146           0 :     m_pTimeField->SetDuration(true);
     147           0 :     m_pTimeField->EnforceValidValue(true);
     148           0 :     m_pTimeField->SetMax(tools::Time(0, 0, 59, 99*tools::Time::nanoPerCenti));
     149           0 :     get(m_pLbLoopCount, "loopcount");
     150           0 :     get(m_pBtnGetOneObject, "getone");
     151           0 :     get(m_pBtnGetAllObjects, "getall");
     152           0 :     get(m_pBtnRemoveBitmap, "delone");
     153           0 :     get(m_pBtnRemoveAll, "delall");
     154           0 :     get(m_pFiCount, "count");
     155           0 :     get(m_pRbtGroup, "group");
     156           0 :     get(m_pRbtBitmap, "bitmap");
     157           0 :     get(m_pFtAdjustment, "alignmentft");
     158           0 :     get(m_pLbAdjustment, "alignment");
     159           0 :     get(m_pBtnCreateGroup, "create");
     160             : 
     161           0 :     m_pCtlDisplay = VclPtr<SdDisplay>::Create(get<Window>("box"));
     162           0 :     m_pCtlDisplay->set_hexpand(true);
     163           0 :     m_pCtlDisplay->set_vexpand(true);
     164           0 :     m_pCtlDisplay->Show();
     165             : 
     166             :     //undo SfxDockingWindow HelpId clear hack
     167           0 :     reverseUniqueHelpIdHack(*this);
     168             : 
     169             :     // create new document with page
     170           0 :     pMyDoc = new SdDrawDocument(DOCUMENT_TYPE_IMPRESS, NULL);
     171           0 :     SdPage* pPage = pMyDoc->AllocSdPage(false);
     172           0 :     pMyDoc->InsertPage(pPage);
     173             : 
     174           0 :     pControllerItem = new AnimationControllerItem( SID_ANIMATOR_STATE, this, pBindings );
     175             : 
     176             :     // as long as not in the resource
     177           0 :     m_pTimeField->SetFormat( TimeFieldFormat::F_SEC_CS );
     178             : 
     179           0 :     m_pBtnFirst->SetClickHdl( LINK( this, AnimationWindow, ClickFirstHdl ) );
     180           0 :     m_pBtnReverse->SetClickHdl( LINK( this, AnimationWindow, ClickPlayHdl ) );
     181           0 :     m_pBtnStop->SetClickHdl( LINK( this, AnimationWindow, ClickStopHdl ) );
     182           0 :     m_pBtnPlay->SetClickHdl( LINK( this, AnimationWindow, ClickPlayHdl ) );
     183           0 :     m_pBtnLast->SetClickHdl( LINK( this, AnimationWindow, ClickLastHdl ) );
     184             : 
     185           0 :     m_pBtnGetOneObject->SetClickHdl( LINK( this, AnimationWindow, ClickGetObjectHdl ) );
     186           0 :     m_pBtnGetAllObjects->SetClickHdl( LINK( this, AnimationWindow, ClickGetObjectHdl ) );
     187           0 :     m_pBtnRemoveBitmap->SetClickHdl( LINK( this, AnimationWindow, ClickRemoveBitmapHdl ) );
     188           0 :     m_pBtnRemoveAll->SetClickHdl( LINK( this, AnimationWindow, ClickRemoveBitmapHdl ) );
     189             : 
     190           0 :     m_pRbtGroup->SetClickHdl( LINK( this, AnimationWindow, ClickRbtHdl ) );
     191           0 :     m_pRbtBitmap->SetClickHdl( LINK( this, AnimationWindow, ClickRbtHdl ) );
     192           0 :     m_pBtnCreateGroup->SetClickHdl( LINK( this, AnimationWindow, ClickCreateGroupHdl ) );
     193           0 :     m_pNumFldBitmap->SetModifyHdl( LINK( this, AnimationWindow, ModifyBitmapHdl ) );
     194           0 :     m_pTimeField->SetModifyHdl( LINK( this, AnimationWindow, ModifyTimeHdl ) );
     195             : 
     196             :     // disable 3D border
     197           0 :     m_pCtlDisplay->SetBorderStyle(WindowBorderStyle::MONO);
     198             : 
     199           0 :     SetMinOutputSizePixel(GetOptimalSize());
     200             : 
     201           0 :     ResetAttrs();
     202             : 
     203             :     // the animator is empty; no animation group can be created
     204           0 :     m_pBtnCreateGroup->Disable();
     205           0 : }
     206             : 
     207           0 : AnimationWindow::~AnimationWindow()
     208             : {
     209           0 :     disposeOnce();
     210           0 : }
     211             : 
     212           0 : void AnimationWindow::dispose()
     213             : {
     214           0 :     DELETEZ( pControllerItem );
     215             : 
     216           0 :     for (size_t i = 0; i < m_FrameList.size(); ++i)
     217             :     {
     218           0 :         delete m_FrameList[i].first;
     219           0 :         delete m_FrameList[i].second;
     220             :     }
     221           0 :     m_FrameList.clear();
     222           0 :     m_nCurrentFrame = EMPTY_FRAMELIST;
     223             : 
     224             :     // delete the clones
     225           0 :     delete pMyDoc;
     226             : 
     227           0 :     m_pCtlDisplay.disposeAndClear();
     228           0 :     m_pBtnFirst.clear();
     229           0 :     m_pBtnReverse.clear();
     230           0 :     m_pBtnStop.clear();
     231           0 :     m_pBtnPlay.clear();
     232           0 :     m_pBtnLast.clear();
     233           0 :     m_pNumFldBitmap.clear();
     234           0 :     m_pTimeField.clear();
     235           0 :     m_pLbLoopCount.clear();
     236           0 :     m_pBtnGetOneObject.clear();
     237           0 :     m_pBtnGetAllObjects.clear();
     238           0 :     m_pBtnRemoveBitmap.clear();
     239           0 :     m_pBtnRemoveAll.clear();
     240           0 :     m_pFiCount.clear();
     241           0 :     m_pRbtGroup.clear();
     242           0 :     m_pRbtBitmap.clear();
     243           0 :     m_pFtAdjustment.clear();
     244           0 :     m_pLbAdjustment.clear();
     245           0 :     m_pBtnCreateGroup.clear();
     246           0 :     pWin.clear();
     247           0 :     SfxDockingWindow::dispose();
     248           0 : }
     249             : 
     250           0 : IMPL_LINK_NOARG(AnimationWindow, ClickFirstHdl)
     251             : {
     252           0 :     m_nCurrentFrame = (m_FrameList.empty()) ? EMPTY_FRAMELIST : 0;
     253           0 :     UpdateControl();
     254             : 
     255           0 :     return 0L;
     256             : }
     257             : 
     258           0 : IMPL_LINK_NOARG(AnimationWindow, ClickStopHdl)
     259             : {
     260           0 :     bMovie = false;
     261           0 :     return 0L;
     262             : }
     263             : 
     264           0 : IMPL_LINK( AnimationWindow, ClickPlayHdl, void *, p )
     265             : {
     266           0 :     ScopeLockGuard aGuard( maPlayLock );
     267             : 
     268           0 :     bMovie = true;
     269           0 :     bool bDisableCtrls = false;
     270           0 :     size_t const nCount = m_FrameList.size();
     271           0 :     bool bReverse = p == m_pBtnReverse;
     272             : 
     273             :     // it is difficult to find it later on
     274           0 :     bool bRbtGroupEnabled = m_pRbtGroup->IsEnabled();
     275           0 :     bool bBtnGetAllObjectsEnabled = m_pBtnGetAllObjects->IsEnabled();
     276           0 :     bool bBtnGetOneObjectEnabled = m_pBtnGetOneObject->IsEnabled();
     277             : 
     278             :     // calculate overall time
     279           0 :     tools::Time aTime( 0 );
     280             :     long nFullTime;
     281           0 :     if( m_pRbtBitmap->IsChecked() )
     282             :     {
     283           0 :         for (size_t i = 0; i < nCount; ++i)
     284             :         {
     285           0 :             aTime += *m_FrameList[i].second;
     286             :         }
     287           0 :         nFullTime  = aTime.GetMSFromTime();
     288             :     }
     289             :     else
     290             :     {
     291           0 :         nFullTime = nCount * 100;
     292           0 :         aTime.MakeTimeFromMS( nFullTime );
     293             :     }
     294             : 
     295             :     // StatusBarManager from 1 second
     296           0 :     SfxProgress* pProgress = NULL;
     297           0 :     if( nFullTime >= 1000 )
     298             :     {
     299           0 :         bDisableCtrls = true;
     300           0 :         m_pBtnStop->Enable();
     301           0 :         m_pBtnStop->Update();
     302           0 :         OUString aStr("Animator:"); // here we should think about something smart
     303           0 :         pProgress = new SfxProgress( NULL, aStr, nFullTime );
     304             :     }
     305             : 
     306           0 :     sal_uLong nTmpTime = 0;
     307           0 :     size_t i = 0;
     308           0 :     bool bCount = i < nCount;
     309           0 :     if( bReverse )
     310             :     {
     311           0 :         i = nCount - 1;
     312             :     }
     313           0 :     while( bCount && bMovie )
     314             :     {
     315             :         // make list and view consistent
     316             :         assert(i < m_FrameList.size());
     317           0 :         m_nCurrentFrame = i;
     318             : 
     319           0 :         UpdateControl(bDisableCtrls);
     320             : 
     321           0 :         if( m_pRbtBitmap->IsChecked() )
     322             :         {
     323           0 :             tools::Time *const pTime = m_FrameList[i].second;
     324             :             assert(pTime);
     325             : 
     326           0 :             m_pTimeField->SetTime( *pTime );
     327           0 :             sal_uLong nTime = pTime->GetMSFromTime();
     328             : 
     329           0 :             WaitInEffect( nTime, nTmpTime, pProgress );
     330           0 :             nTmpTime += nTime;
     331             :         }
     332             :         else
     333             :         {
     334           0 :             WaitInEffect( 100, nTmpTime, pProgress );
     335           0 :             nTmpTime += 100;
     336             :         }
     337           0 :         if( bReverse )
     338             :         {
     339           0 :             if (i == 0)
     340             :             {
     341             :                 // Terminate loop.
     342           0 :                 bCount = false;
     343             :             }
     344             :             else
     345             :             {
     346           0 :                 --i;
     347             :             }
     348             :         }
     349             :         else
     350             :         {
     351           0 :             i++;
     352           0 :             if (i >= nCount)
     353             :             {
     354             :                 // Terminate loop.
     355           0 :                 bCount = false;
     356             :                 // Move i back into valid range.
     357           0 :                 i = nCount - 1;
     358             :             }
     359             :         }
     360             :     }
     361             : 
     362             :     // to re-enable the controls
     363           0 :     bMovie = false;
     364           0 :     if (nCount > 0)
     365             :     {
     366             :         assert(i == m_nCurrentFrame);
     367           0 :         UpdateControl();
     368             :     }
     369             : 
     370           0 :     if( pProgress )
     371             :     {
     372           0 :         delete pProgress;
     373           0 :         m_pBtnStop->Disable();
     374             :     }
     375             : 
     376           0 :     m_pRbtGroup->Enable( bRbtGroupEnabled );
     377           0 :     m_pBtnGetAllObjects->Enable( bBtnGetAllObjectsEnabled );
     378           0 :     m_pBtnGetOneObject->Enable( bBtnGetOneObjectEnabled );
     379             : 
     380           0 :     return 0L;
     381             : }
     382             : 
     383           0 : IMPL_LINK_NOARG(AnimationWindow, ClickLastHdl)
     384             : {
     385             :     m_nCurrentFrame =
     386           0 :         (m_FrameList.empty()) ? EMPTY_FRAMELIST : m_FrameList.size() - 1 ;
     387           0 :     UpdateControl();
     388             : 
     389           0 :     return 0L;
     390             : }
     391             : 
     392           0 : IMPL_LINK( AnimationWindow, ClickRbtHdl, void *, p )
     393             : {
     394           0 :     if (m_FrameList.empty() || p == m_pRbtGroup || m_pRbtGroup->IsChecked())
     395             :     {
     396           0 :         m_pTimeField->SetText( OUString() );
     397           0 :         m_pTimeField->Enable( false );
     398           0 :         m_pLbLoopCount->Enable( false );
     399             :     }
     400           0 :     else if( p == m_pRbtBitmap || m_pRbtBitmap->IsChecked() )
     401             :     {
     402           0 :         sal_uLong n = static_cast<sal_uLong>(m_pNumFldBitmap->GetValue());
     403           0 :         if( n > 0 )
     404             :         {
     405           0 :             tools::Time *const pTime = m_FrameList[n - 1].second;
     406           0 :             if( pTime )
     407           0 :                 m_pTimeField->SetTime( *pTime );
     408             :         }
     409           0 :         m_pTimeField->Enable();
     410           0 :         m_pLbLoopCount->Enable();
     411             :     }
     412             : 
     413           0 :     return 0L;
     414             : }
     415             : 
     416           0 : IMPL_LINK( AnimationWindow, ClickGetObjectHdl, void *, pBtn )
     417             : {
     418           0 :     bAllObjects = pBtn == m_pBtnGetAllObjects;
     419             : 
     420             :     // Code now in AddObj()
     421           0 :     SfxBoolItem aItem( SID_ANIMATOR_ADD, true );
     422             : 
     423           0 :     GetBindings().GetDispatcher()->Execute(
     424           0 :         SID_ANIMATOR_ADD, SfxCallMode::SLOT | SfxCallMode::RECORD, &aItem, 0L );
     425           0 :     return 0L;
     426             : }
     427             : 
     428           0 : IMPL_LINK( AnimationWindow, ClickRemoveBitmapHdl, void *, pBtn )
     429             : {
     430           0 :     SdPage*     pPage = pMyDoc->GetSdPage(0, PK_STANDARD);
     431             :     SdrObject*  pObject;
     432             : 
     433           0 :     if (pBtn == m_pBtnRemoveBitmap)
     434             :     {
     435           0 :         delete m_FrameList[m_nCurrentFrame].first;
     436           0 :         delete m_FrameList[m_nCurrentFrame].second;
     437           0 :         m_FrameList.erase(m_FrameList.begin() + m_nCurrentFrame);
     438             : 
     439           0 :         pObject = pPage->GetObj(m_nCurrentFrame);
     440             :         // Through acquisition of the AnimatedGIFs, objects does not need to
     441             :         // exist.
     442           0 :         if( pObject )
     443             :         {
     444           0 :             pObject = pPage->RemoveObject(m_nCurrentFrame);
     445             :             DBG_ASSERT(pObject, "Clone not found during deletion");
     446           0 :             SdrObject::Free( pObject );
     447           0 :             pPage->RecalcObjOrdNums();
     448             :         }
     449             : 
     450           0 :         if (m_nCurrentFrame >= m_FrameList.size())
     451             :         {
     452             :             assert(m_FrameList.empty());
     453           0 :             m_nCurrentFrame = EMPTY_FRAMELIST;
     454             :         }
     455             :     }
     456             :     else // delete everything
     457             :     {
     458           0 :         ScopedVclPtrInstance< WarningBox > aWarnBox( this, WB_YES_NO, SD_RESSTR( STR_ASK_DELETE_ALL_PICTURES ) );
     459           0 :         short nReturn = aWarnBox->Execute();
     460             : 
     461           0 :         if( nReturn == RET_YES )
     462             :         {
     463             :             // clear frame list
     464           0 :             for (size_t i = m_FrameList.size(); i > 0; )
     465             :             {
     466           0 :                 --i;
     467           0 :                 delete m_FrameList[i].first;
     468             : 
     469           0 :                 pObject = pPage->GetObj( i );
     470           0 :                 if( pObject )
     471             :                 {
     472           0 :                     pObject = pPage->RemoveObject( i );
     473             :                     DBG_ASSERT(pObject, "Clone not found during deletion");
     474           0 :                     SdrObject::Free( pObject );
     475             :                     //pPage->RecalcObjOrdNums();
     476             :                 }
     477             : 
     478           0 :                 delete m_FrameList[i].second;
     479             :             }
     480           0 :             m_FrameList.clear();
     481           0 :             m_nCurrentFrame = EMPTY_FRAMELIST;
     482           0 :         }
     483             :     }
     484             : 
     485             :     // can we create a animation group
     486           0 :     if (m_FrameList.empty())
     487             :     {
     488           0 :         m_pBtnCreateGroup->Disable();
     489             :         // if previous disabled by acquisition of AnimatedGIFs:
     490             :         //m_pRbtBitmap->Enable();
     491           0 :         m_pRbtGroup->Enable();
     492             :     }
     493             : 
     494             :     // calculate and set zoom for DisplayWin
     495           0 :     Fraction aFrac(GetScale());
     496           0 :     m_pCtlDisplay->SetScale(aFrac);
     497             : 
     498           0 :     UpdateControl();
     499             : 
     500           0 :     return 0L;
     501             : }
     502             : 
     503           0 : IMPL_LINK_NOARG(AnimationWindow, ClickCreateGroupHdl)
     504             : {
     505             :     // Code now in CreatePresObj()
     506           0 :     SfxBoolItem aItem( SID_ANIMATOR_CREATE, true );
     507             : 
     508           0 :     GetBindings().GetDispatcher()->Execute(
     509           0 :         SID_ANIMATOR_CREATE, SfxCallMode::SLOT | SfxCallMode::RECORD, &aItem, 0L );
     510           0 :     return 0L;
     511             : }
     512             : 
     513           0 : IMPL_LINK_NOARG(AnimationWindow, ModifyBitmapHdl)
     514             : {
     515           0 :     sal_uLong nBmp = static_cast<sal_uLong>(m_pNumFldBitmap->GetValue());
     516             : 
     517           0 :     if (nBmp > m_FrameList.size())
     518             :     {
     519           0 :         nBmp = m_FrameList.size();
     520             :     }
     521             : 
     522           0 :     m_nCurrentFrame = nBmp - 1;
     523             : 
     524           0 :     UpdateControl();
     525             : 
     526           0 :     return 0L;
     527             : }
     528             : 
     529           0 : IMPL_LINK_NOARG(AnimationWindow, ModifyTimeHdl)
     530             : {
     531           0 :     sal_uLong nPos = static_cast<sal_uLong>(m_pNumFldBitmap->GetValue() - 1);
     532             : 
     533           0 :     tools::Time *const pTime = m_FrameList[nPos].second;
     534             : 
     535           0 :     *pTime = m_pTimeField->GetTime();
     536             : 
     537           0 :     return 0L;
     538             : }
     539             : 
     540           0 : void AnimationWindow::UpdateControl(bool const bDisableCtrls)
     541             : {
     542           0 :     if (!m_FrameList.empty())
     543             :     {
     544           0 :         BitmapEx aBmp(*m_FrameList[m_nCurrentFrame].first);
     545             : 
     546           0 :         SdPage* pPage = pMyDoc->GetSdPage(0, PK_STANDARD);
     547             :         SdrObject *const pObject =
     548           0 :             static_cast<SdrObject*>(pPage->GetObj(m_nCurrentFrame));
     549           0 :         if( pObject )
     550             :         {
     551           0 :             ScopedVclPtrInstance< VirtualDevice > pVD;
     552           0 :             Rectangle       aObjRect( pObject->GetCurrentBoundRect() );
     553           0 :             Size            aObjSize( aObjRect.GetSize() );
     554           0 :             Point           aOrigin( Point( -aObjRect.Left(), -aObjRect.Top() ) );
     555           0 :             MapMode         aMap( pVD->GetMapMode() );
     556           0 :             aMap.SetMapUnit( MAP_100TH_MM );
     557           0 :             aMap.SetOrigin( aOrigin );
     558           0 :             pVD->SetMapMode( aMap );
     559           0 :             pVD->SetOutputSize( aObjSize );
     560           0 :             const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
     561           0 :             pVD->SetBackground( Wallpaper( rStyles.GetFieldColor() ) );
     562           0 :             pVD->SetDrawMode( rStyles.GetHighContrastMode()
     563             :                 ? sd::OUTPUT_DRAWMODE_CONTRAST
     564           0 :                 : sd::OUTPUT_DRAWMODE_COLOR );
     565           0 :             pVD->Erase();
     566           0 :             pObject->SingleObjectPainter( *pVD.get() );
     567           0 :             aBmp = BitmapEx( pVD->GetBitmap( aObjRect.TopLeft(), aObjSize ) );
     568             :         }
     569             : 
     570           0 :         m_pCtlDisplay->SetBitmapEx(&aBmp);
     571             :     }
     572             :     else
     573             :     {
     574           0 :         m_pCtlDisplay->SetBitmapEx(0);
     575             :     }
     576           0 :     m_pCtlDisplay->Invalidate();
     577           0 :     m_pCtlDisplay->Update();
     578             : 
     579           0 :     m_pFiCount->SetText(OUString::number(
     580           0 :                 m_FrameList.size()));
     581             : 
     582           0 :     if (!m_FrameList.empty() && !bMovie)
     583             :     {
     584           0 :         size_t nIndex = m_nCurrentFrame + 1;
     585           0 :         m_pNumFldBitmap->SetValue(nIndex);
     586             : 
     587             :         // if there is at least 1 object in the list
     588           0 :         m_pBtnFirst->Enable();
     589           0 :         m_pBtnReverse->Enable();
     590           0 :         m_pBtnPlay->Enable();
     591           0 :         m_pBtnLast->Enable();
     592           0 :         m_pNumFldBitmap->Enable();
     593           0 :         m_pTimeField->Enable();
     594           0 :         m_pLbLoopCount->Enable();
     595           0 :         m_pBtnRemoveBitmap->Enable();
     596           0 :         m_pBtnRemoveAll->Enable();
     597             :     }
     598             :     else
     599             :     {
     600             :         // if no object is in the list
     601           0 :         m_pBtnFirst->Enable( false );
     602           0 :         m_pBtnReverse->Enable( false );
     603           0 :         m_pBtnPlay->Enable( false );
     604           0 :         m_pBtnLast->Enable( false );
     605           0 :         m_pNumFldBitmap->Enable( false );
     606           0 :         m_pTimeField->Enable( false );
     607           0 :         m_pLbLoopCount->Enable( false );
     608           0 :         m_pBtnRemoveBitmap->Enable( false );
     609           0 :         m_pBtnRemoveAll->Enable( false );
     610             :     }
     611             : 
     612           0 :     if( bMovie && bDisableCtrls )
     613             :     {
     614           0 :         m_pBtnGetOneObject->Enable( false );
     615           0 :         m_pBtnGetAllObjects->Enable( false );
     616           0 :         m_pRbtGroup->Enable( false );
     617           0 :         m_pRbtBitmap->Enable( false );
     618           0 :         m_pBtnCreateGroup->Enable( false );
     619           0 :         m_pFtAdjustment->Enable( false );
     620           0 :         m_pLbAdjustment->Enable( false );
     621             :     }
     622             :     else
     623             :     {
     624             :         // enable 'group object' only if it is not a Animated GIF
     625           0 :         if (m_FrameList.empty())
     626             :         {
     627           0 :             m_pRbtGroup->Enable();
     628             :         }
     629             : 
     630           0 :         m_pRbtBitmap->Enable();
     631           0 :         m_pBtnCreateGroup->Enable(!m_FrameList.empty());
     632           0 :         m_pFtAdjustment->Enable( true );
     633           0 :         m_pLbAdjustment->Enable( true );
     634             :     }
     635             : 
     636           0 :     ClickRbtHdl( NULL );
     637           0 : }
     638             : 
     639           0 : void AnimationWindow::ResetAttrs()
     640             : {
     641           0 :     m_pRbtGroup->Check();
     642           0 :     m_pLbAdjustment->SelectEntryPos( BA_CENTER );
     643             :     // LoopCount
     644           0 :     m_pLbLoopCount->SelectEntryPos( m_pLbLoopCount->GetEntryCount() - 1);
     645             : 
     646           0 :     UpdateControl();
     647           0 : }
     648             : 
     649           0 : void AnimationWindow::WaitInEffect( sal_uLong nMilliSeconds, sal_uLong nTime,
     650             :                                     SfxProgress* pProgress ) const
     651             : {
     652           0 :     sal_uInt64 aEnd = tools::Time::GetSystemTicks() + nMilliSeconds;
     653           0 :     sal_uInt64 aCurrent = tools::Time::GetSystemTicks();
     654           0 :     while (aCurrent < aEnd)
     655             :     {
     656           0 :         aCurrent = tools::Time::GetSystemTicks();
     657             : 
     658           0 :         if( pProgress )
     659           0 :             pProgress->SetState( nTime + nMilliSeconds + aCurrent - aEnd );
     660             : 
     661           0 :         Application::Reschedule();
     662             : 
     663           0 :         if( !bMovie )
     664           0 :             return;
     665             :     }
     666             : }
     667             : 
     668           0 : Fraction AnimationWindow::GetScale()
     669             : {
     670           0 :     Fraction aFrac;
     671           0 :     size_t const nCount = m_FrameList.size();
     672           0 :     if (nCount > 0)
     673             :     {
     674           0 :         Size aBmpSize(0, 0);
     675           0 :         for (size_t i = 0; i < nCount; i++)
     676             :         {
     677           0 :             BitmapEx *const pBitmap = m_FrameList[i].first;
     678           0 :             Size aTempSize( pBitmap->GetBitmap().GetSizePixel() );
     679           0 :             aBmpSize.Width() = std::max( aBmpSize.Width(), aTempSize.Width() );
     680           0 :             aBmpSize.Height() = std::max( aBmpSize.Height(), aTempSize.Height() );
     681             :         }
     682             : 
     683           0 :         aBmpSize.Width() += 10;
     684           0 :         aBmpSize.Height() += 10;
     685             : 
     686           0 :         Size aDisplaySize(m_pCtlDisplay->GetOutputSize());
     687             : 
     688           0 :         aFrac = Fraction( std::min( (double)aDisplaySize.Width() / (double)aBmpSize.Width(),
     689           0 :                              (double)aDisplaySize.Height() / (double)aBmpSize.Height() ) );
     690             :     }
     691           0 :     return aFrac;
     692             : }
     693             : 
     694           0 : void AnimationWindow::Resize()
     695             : {
     696           0 :     SfxDockingWindow::Resize();
     697           0 :     Fraction aFrac(GetScale());
     698           0 :     m_pCtlDisplay->SetScale(aFrac);
     699           0 : }
     700             : 
     701           0 : bool AnimationWindow::Close()
     702             : {
     703           0 :     if( maPlayLock.isLocked() )
     704             :     {
     705           0 :         return false;
     706             :     }
     707             :     else
     708             :     {
     709           0 :         SfxBoolItem aItem( SID_ANIMATION_OBJECTS, false );
     710             : 
     711           0 :         GetBindings().GetDispatcher()->Execute(
     712           0 :             SID_ANIMATION_OBJECTS, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, &aItem, 0L );
     713             : 
     714           0 :         SfxDockingWindow::Close();
     715             : 
     716           0 :         return true;
     717             :     }
     718             : }
     719             : 
     720           0 : void AnimationWindow::FillInfo( SfxChildWinInfo& rInfo ) const
     721             : {
     722           0 :     SfxDockingWindow::FillInfo( rInfo ) ;
     723           0 : }
     724             : 
     725           0 : void AnimationWindow::AddObj (::sd::View& rView )
     726             : {
     727             :     // finish text entry mode to ensure that bitmap is identical with object
     728           0 :     if( rView.IsTextEdit() )
     729           0 :         rView.SdrEndTextEdit();
     730             : 
     731             :     // clone object(s) and insert the clone(s) into the list
     732           0 :     const SdrMarkList& rMarkList   = rView.GetMarkedObjectList();
     733           0 :     const size_t nMarkCount = rMarkList.GetMarkCount();
     734           0 :     SdPage*            pPage       = pMyDoc->GetSdPage(0, PK_STANDARD);
     735           0 :     const size_t nCloneCount = pPage->GetObjCount();
     736             : 
     737           0 :     if (nMarkCount > 0)
     738             :     {
     739             :         // If it is ONE animation object or one group object, which was
     740             :         // 'individually taken', we insert the objects separately
     741           0 :         bool bAnimObj = false;
     742           0 :         if( nMarkCount == 1 )
     743             :         {
     744           0 :             SdrMark*            pMark = rMarkList.GetMark(0);
     745           0 :             SdrObject*          pObject = pMark->GetMarkedSdrObj();
     746           0 :             SdAnimationInfo*    pAnimInfo = rView.GetDoc().GetAnimationInfo( pObject );
     747           0 :             sal_uInt32              nInv = pObject->GetObjInventor();
     748           0 :             sal_uInt16              nId = pObject->GetObjIdentifier();
     749             : 
     750             :             // Animated Bitmap (GIF)
     751           0 :             if( nInv == SdrInventor && nId == OBJ_GRAF && static_cast<SdrGrafObj*>( pObject )->IsAnimated() )
     752             :             {
     753           0 :                 const SdrGrafObj*   pGrafObj = static_cast<SdrGrafObj*>(pObject);
     754           0 :                 Graphic             aGraphic( pGrafObj->GetTransformedGraphic() );
     755           0 :                 sal_uInt16              nCount = 0;
     756             : 
     757           0 :                 if( aGraphic.IsAnimated() )
     758           0 :                     nCount = aGraphic.GetAnimation().Count();
     759             : 
     760           0 :                 if( nCount > 0 )
     761             :                 {
     762           0 :                     const Animation aAnimation( aGraphic.GetAnimation() );
     763             : 
     764           0 :                     for( sal_uInt16 i = 0; i < nCount; i++ )
     765             :                     {
     766           0 :                         const AnimationBitmap& rAnimBmp = aAnimation.Get( i );
     767             : 
     768             :                         BitmapEx *const pBitmapEx =
     769           0 :                             new BitmapEx(rAnimBmp.aBmpEx);
     770             : 
     771             :                         // LoopCount
     772           0 :                         if( i == 0 )
     773             :                         {
     774           0 :                             long nLoopCount = aAnimation.GetLoopCount();
     775             : 
     776           0 :                             if( !nLoopCount ) // endless
     777           0 :                                 m_pLbLoopCount->SelectEntryPos( m_pLbLoopCount->GetEntryCount() - 1);
     778             :                             else
     779           0 :                                 m_pLbLoopCount->SelectEntry(OUString::number( nLoopCount ) );
     780             :                         }
     781             : 
     782           0 :                         long nTime = rAnimBmp.nWait;
     783           0 :                         ::tools::Time* pTime = new ::tools::Time( 0, 0, nTime / 100, nTime % 100 );
     784           0 :                         size_t nIndex = m_nCurrentFrame + 1;
     785             :                         m_FrameList.insert(
     786           0 :                                 m_FrameList.begin() + nIndex,
     787           0 :                                 ::std::make_pair(pBitmapEx, pTime));
     788             : 
     789             :                         // increment => next one inserted after this one
     790           0 :                         ++m_nCurrentFrame;
     791             :                     }
     792             :                     // if a animated GIF is taken, only such one can be created
     793           0 :                     m_pRbtBitmap->Check();
     794           0 :                     m_pRbtGroup->Enable( false );
     795           0 :                     bAnimObj = true;
     796           0 :                 }
     797             :             }
     798           0 :             else if( bAllObjects || ( pAnimInfo && pAnimInfo->mbIsMovie ) )
     799             :             {
     800             :                 // several objects
     801           0 :                 SdrObjList* pObjList = static_cast<SdrObjGroup*>(pObject)->GetSubList();
     802             : 
     803           0 :                 for( size_t nObject = 0; nObject < pObjList->GetObjCount(); ++nObject )
     804             :                 {
     805           0 :                     SdrObject* pSnapShot = pObjList->GetObj( nObject );
     806             : 
     807             :                     BitmapEx *const pBitmapEx = new BitmapEx(
     808             :                         SdrExchangeView::GetObjGraphic(
     809           0 :                             pSnapShot->GetModel(), pSnapShot).GetBitmapEx() );
     810             : 
     811           0 :                     ::tools::Time* pTime = new ::tools::Time( m_pTimeField->GetTime() );
     812           0 :                     size_t nIndex = m_nCurrentFrame + 1;
     813             :                     m_FrameList.insert(
     814           0 :                             m_FrameList.begin() + nIndex,
     815           0 :                             ::std::make_pair(pBitmapEx, pTime));
     816             : 
     817             :                     // increment => next one inserted after this one
     818           0 :                     ++m_nCurrentFrame;
     819             : 
     820             :                     // Clone
     821           0 :                     pPage->InsertObject(pSnapShot->Clone(), m_nCurrentFrame);
     822             :                 }
     823           0 :                 bAnimObj = true;
     824             :             }
     825             :         }
     826             :         // also one single animated object
     827           0 :         if( !bAnimObj && !( bAllObjects && nMarkCount > 1 ) )
     828             :         {
     829             :             BitmapEx *const pBitmapEx =
     830           0 :                 new BitmapEx(rView.GetAllMarkedGraphic().GetBitmapEx());
     831             : 
     832           0 :             ::tools::Time* pTime = new ::tools::Time( m_pTimeField->GetTime() );
     833             : 
     834           0 :             size_t nIndex = m_nCurrentFrame + 1;
     835             :             m_FrameList.insert(
     836           0 :                     m_FrameList.begin() + nIndex,
     837           0 :                     ::std::make_pair(pBitmapEx, pTime));
     838             :         }
     839             : 
     840             :         // one single object
     841           0 :         if( nMarkCount == 1 && !bAnimObj )
     842             :         {
     843           0 :             SdrMark*    pMark   = rMarkList.GetMark(0);
     844           0 :             SdrObject*  pObject = pMark->GetMarkedSdrObj();
     845           0 :             SdrObject*  pClone  = pObject->Clone();
     846           0 :             size_t nIndex = m_nCurrentFrame + 1;
     847           0 :             pPage->InsertObject(pClone, nIndex);
     848             :         }
     849             :         // several objects: group the clones
     850           0 :         else if (nMarkCount > 1)
     851             :         {
     852             :             // take objects separately
     853           0 :             if( bAllObjects )
     854             :             {
     855           0 :                 for( size_t nObject= 0; nObject < nMarkCount; ++nObject )
     856             :                 {
     857             :                     // Clone
     858           0 :                     SdrObject* pObject = rMarkList.GetMark( nObject )->GetMarkedSdrObj();
     859             : 
     860             :                     BitmapEx *const pBitmapEx = new BitmapEx(
     861             :                         SdrExchangeView::GetObjGraphic(
     862           0 :                             pObject->GetModel(), pObject).GetBitmapEx() );
     863             : 
     864           0 :                     ::tools::Time* pTime = new ::tools::Time( m_pTimeField->GetTime() );
     865             : 
     866           0 :                     size_t nIndex = m_nCurrentFrame + 1;
     867             :                     m_FrameList.insert(
     868           0 :                         m_FrameList.begin() + nIndex,
     869           0 :                         ::std::make_pair(pBitmapEx, pTime));
     870             : 
     871             :                     // increment => next one inserted after this one
     872           0 :                     ++m_nCurrentFrame;
     873             : 
     874           0 :                     pPage->InsertObject(pObject->Clone(), m_nCurrentFrame);
     875             :                 }
     876           0 :                 bAnimObj = true; // that we don't change again
     877             :             }
     878             :             else
     879             :             {
     880           0 :                 SdrObjGroup* pCloneGroup = new SdrObjGroup;
     881           0 :                 SdrObjList*  pObjList    = pCloneGroup->GetSubList();
     882             : 
     883           0 :                 for (size_t nObject= 0; nObject < nMarkCount; ++nObject)
     884           0 :                     pObjList->InsertObject(rMarkList.GetMark(nObject)->GetMarkedSdrObj()->Clone());
     885             : 
     886           0 :                 size_t nIndex = m_nCurrentFrame + 1;
     887           0 :                 pPage->InsertObject(pCloneGroup, nIndex);
     888             :             }
     889             :         }
     890             : 
     891           0 :         if( !bAnimObj )
     892             :         {
     893           0 :             ++m_nCurrentFrame;
     894             :         }
     895             : 
     896             :         // if there was nothing in the animator before but now is something
     897             :         // there, we can create a animation group
     898           0 :         if (nCloneCount == 0 && !m_FrameList.empty())
     899             :         {
     900           0 :             m_pBtnCreateGroup->Enable();
     901             :         }
     902             : 
     903             :         // calculate and set zoom for DisplayWin
     904           0 :         Fraction aFrac( GetScale() );
     905           0 :         m_pCtlDisplay->SetScale(aFrac);
     906             : 
     907           0 :         UpdateControl();
     908             :     }
     909           0 : }
     910             : 
     911           0 : void AnimationWindow::CreateAnimObj (::sd::View& rView )
     912             : {
     913           0 :     vcl::Window* pOutWin = static_cast< vcl::Window*>(rView.GetFirstOutputDevice()); // GetWin( 0 );
     914             :     DBG_ASSERT( pOutWin, "Window does not exist!" );
     915             : 
     916             :     // find window center
     917           0 :     const MapMode       aMap100( MAP_100TH_MM );
     918           0 :     Size                aMaxSizeLog;
     919           0 :     Size                aMaxSizePix;
     920           0 :     Size                aTemp( pOutWin->GetOutputSizePixel() );
     921           0 :     const Point         aWindowCenter( pOutWin->PixelToLogic( Point( aTemp.Width() >> 1, aTemp.Height() >> 1 ) ) );
     922           0 :     const OutputDevice* pDefDev = Application::GetDefaultDevice();
     923           0 :     const size_t nCount = m_FrameList.size();
     924           0 :     BitmapAdjustment    eBA = (BitmapAdjustment) m_pLbAdjustment->GetSelectEntryPos();
     925             : 
     926             :     // find biggest bitmap
     927           0 :     for (size_t i = 0; i < nCount; ++i)
     928             :     {
     929           0 :         const BitmapEx& rBmpEx = *m_FrameList[i].first;
     930           0 :         const Graphic   aGraphic( rBmpEx );
     931           0 :         Size            aTmpSizeLog;
     932           0 :         const Size      aTmpSizePix( rBmpEx.GetSizePixel() );
     933             : 
     934           0 :         if ( aGraphic.GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
     935           0 :             aTmpSizeLog = pDefDev->PixelToLogic( aGraphic.GetPrefSize(), aMap100 );
     936             :         else
     937           0 :             aTmpSizeLog = OutputDevice::LogicToLogic( aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(), aMap100 );
     938             : 
     939           0 :         aMaxSizeLog.Width() = std::max( aMaxSizeLog.Width(), aTmpSizeLog.Width() );
     940           0 :         aMaxSizeLog.Height() = std::max( aMaxSizeLog.Height(), aTmpSizeLog.Height() );
     941             : 
     942           0 :         aMaxSizePix.Width() = std::max( aMaxSizePix.Width(), aTmpSizePix.Width() );
     943           0 :         aMaxSizePix.Height() = std::max( aMaxSizePix.Height(), aTmpSizePix.Height() );
     944           0 :     }
     945             : 
     946           0 :     SdrPageView* pPV = rView.GetSdrPageView();
     947             : 
     948           0 :     if( m_pRbtBitmap->IsChecked() )
     949             :     {
     950             :         // create bitmap group (Animated GIF)
     951           0 :         Animation   aAnimation;
     952           0 :         Point       aPt;
     953             : 
     954           0 :         for (size_t i = 0; i < nCount; ++i)
     955             :         {
     956           0 :             tools::Time *const pTime = m_FrameList[i].second;
     957           0 :             long  nTime = pTime->GetNanoSec();
     958           0 :             nTime += pTime->GetSec() * 100;
     959             : 
     960           0 :             BitmapEx const*const pBitmapEx = m_FrameList[i].first;
     961             : 
     962             :             // calculate offset for the specified direction
     963           0 :             const Size aBitmapSize( pBitmapEx->GetSizePixel() );
     964             : 
     965           0 :             switch( eBA )
     966             :             {
     967             :                 case BA_LEFT_UP:
     968           0 :                 break;
     969             : 
     970             :                 case BA_LEFT:
     971           0 :                     aPt.Y() = (aMaxSizePix.Height() - aBitmapSize.Height()) >> 1;
     972           0 :                 break;
     973             : 
     974             :                 case BA_LEFT_DOWN:
     975           0 :                     aPt.Y() = aMaxSizePix.Height() - aBitmapSize.Height();
     976           0 :                 break;
     977             : 
     978             :                 case BA_UP:
     979           0 :                     aPt.X() = (aMaxSizePix.Width() - aBitmapSize.Width()) >> 1;
     980           0 :                 break;
     981             : 
     982             :                 case BA_CENTER:
     983           0 :                     aPt.X()  = (aMaxSizePix.Width() - aBitmapSize.Width()) >> 1;
     984           0 :                     aPt.Y() = (aMaxSizePix.Height() - aBitmapSize.Height()) >> 1;
     985           0 :                 break;
     986             : 
     987             :                 case BA_DOWN:
     988           0 :                     aPt.X()  = (aMaxSizePix.Width() - aBitmapSize.Width()) >> 1;
     989           0 :                     aPt.Y() = aMaxSizePix.Height() - aBitmapSize.Height();
     990           0 :                 break;
     991             : 
     992             :                 case BA_RIGHT_UP:
     993           0 :                     aPt.X() = aMaxSizePix.Width() - aBitmapSize.Width();
     994           0 :                 break;
     995             : 
     996             :                 case BA_RIGHT:
     997           0 :                     aPt.X()  = aMaxSizePix.Width() - aBitmapSize.Width();
     998           0 :                     aPt.Y() = (aMaxSizePix.Height() - aBitmapSize.Height()) >> 1;
     999           0 :                 break;
    1000             : 
    1001             :                 case BA_RIGHT_DOWN:
    1002           0 :                     aPt.X()  = aMaxSizePix.Width() - aBitmapSize.Width();
    1003           0 :                     aPt.Y() = aMaxSizePix.Height() - aBitmapSize.Height();
    1004           0 :                 break;
    1005             : 
    1006             :             }
    1007             : 
    1008             :             // find LoopCount (number of passes)
    1009           0 :             AnimationBitmap aAnimBmp;
    1010           0 :             long            nLoopCount = 0L;
    1011           0 :             sal_Int32          nPos = m_pLbLoopCount->GetSelectEntryPos();
    1012             : 
    1013           0 :             if( nPos != LISTBOX_ENTRY_NOTFOUND && nPos != m_pLbLoopCount->GetEntryCount() - 1 ) // endless
    1014           0 :                 nLoopCount = (long) m_pLbLoopCount->GetSelectEntry().toInt32();
    1015             : 
    1016           0 :             aAnimBmp.aBmpEx = *pBitmapEx;
    1017           0 :             aAnimBmp.aPosPix = aPt;
    1018           0 :             aAnimBmp.aSizePix = aBitmapSize;
    1019           0 :             aAnimBmp.nWait = nTime;
    1020           0 :             aAnimBmp.eDisposal = DISPOSE_BACK;
    1021           0 :             aAnimBmp.bUserInput = false;
    1022             : 
    1023           0 :             aAnimation.Insert( aAnimBmp );
    1024           0 :             aAnimation.SetDisplaySizePixel( aMaxSizePix );
    1025           0 :             aAnimation.SetLoopCount( nLoopCount );
    1026           0 :         }
    1027             : 
    1028           0 :         SdrGrafObj* pGrafObj = new SdrGrafObj( Graphic( aAnimation ) );
    1029           0 :         const Point aOrg( aWindowCenter.X() - ( aMaxSizeLog.Width() >> 1 ), aWindowCenter.Y() - ( aMaxSizeLog.Height() >> 1 ) );
    1030             : 
    1031           0 :         pGrafObj->SetLogicRect( Rectangle( aOrg, aMaxSizeLog ) );
    1032           0 :         rView.InsertObjectAtView( pGrafObj, *pPV, SdrInsertFlags::SETDEFLAYER);
    1033             :     }
    1034             :     else
    1035             :     {
    1036             :         // calculate offset for the specified direction
    1037           0 :         Size aOffset;
    1038           0 :         SdrObject * pClone = NULL;
    1039           0 :         SdPage* pPage = pMyDoc->GetSdPage(0, PK_STANDARD);
    1040             : 
    1041           0 :         for (size_t i = 0; i < nCount; ++i)
    1042             :         {
    1043           0 :             pClone = pPage->GetObj(i);
    1044           0 :             Rectangle aRect( pClone->GetSnapRect() );
    1045             : 
    1046           0 :             switch( eBA )
    1047             :             {
    1048             :                 case BA_LEFT_UP:
    1049           0 :                 break;
    1050             : 
    1051             :                 case BA_LEFT:
    1052           0 :                     aOffset.Height() = (aMaxSizeLog.Height() - aRect.GetHeight()) / 2;
    1053           0 :                 break;
    1054             : 
    1055             :                 case BA_LEFT_DOWN:
    1056           0 :                     aOffset.Height() = aMaxSizeLog.Height() - aRect.GetHeight();
    1057           0 :                 break;
    1058             : 
    1059             :                 case BA_UP:
    1060           0 :                     aOffset.Width() = (aMaxSizeLog.Width() - aRect.GetWidth()) / 2;
    1061           0 :                 break;
    1062             : 
    1063             :                 case BA_CENTER:
    1064           0 :                     aOffset.Width()  = (aMaxSizeLog.Width() - aRect.GetWidth()) / 2;
    1065           0 :                     aOffset.Height() = (aMaxSizeLog.Height() - aRect.GetHeight()) / 2;
    1066           0 :                 break;
    1067             : 
    1068             :                 case BA_DOWN:
    1069           0 :                     aOffset.Width()  = (aMaxSizeLog.Width() - aRect.GetWidth()) / 2;
    1070           0 :                     aOffset.Height() = aMaxSizeLog.Height() - aRect.GetHeight();
    1071           0 :                 break;
    1072             : 
    1073             :                 case BA_RIGHT_UP:
    1074           0 :                     aOffset.Width() = aMaxSizeLog.Width() - aRect.GetWidth();
    1075           0 :                 break;
    1076             : 
    1077             :                 case BA_RIGHT:
    1078           0 :                     aOffset.Width()  = aMaxSizeLog.Width() - aRect.GetWidth();
    1079           0 :                     aOffset.Height() = (aMaxSizeLog.Height() - aRect.GetHeight()) / 2;
    1080           0 :                 break;
    1081             : 
    1082             :                 case BA_RIGHT_DOWN:
    1083           0 :                     aOffset.Width()  = aMaxSizeLog.Width() - aRect.GetWidth();
    1084           0 :                     aOffset.Height() = aMaxSizeLog.Height() - aRect.GetHeight();
    1085           0 :                 break;
    1086             : 
    1087             :             }
    1088             :             // Unfortunately, SetSnapRect is not implemented for ellipses !!!
    1089           0 :             Point aMovePt( aWindowCenter + Point( aOffset.Width(), aOffset.Height() ) - aRect.TopLeft() );
    1090           0 :             Size aMoveSize( aMovePt.X(), aMovePt.Y() );
    1091           0 :             pClone->NbcMove( aMoveSize );
    1092             :         }
    1093             : 
    1094             :         // #i42894# Caution(!) variable pPage looks right, but it is a page from the local
    1095             :         // document the dialog is using (!), so get the target page from the target view
    1096           0 :         SdPage* pTargetSdPage = dynamic_cast< SdPage* >(rView.GetSdrPageView() ? rView.GetSdrPageView()->GetPage() : 0);
    1097             : 
    1098           0 :         if(pTargetSdPage)
    1099             :         {
    1100             :             // create animation group
    1101           0 :             SdrObjGroup* pGroup   = new SdrObjGroup;
    1102           0 :             SdrObjList*  pObjList = pGroup->GetSubList();
    1103             : 
    1104           0 :             for (size_t i = 0; i < nCount; ++i)
    1105             :             {
    1106             :                 // the clone remains in the animatior; we insert a clone of the
    1107             :                 // clone into the group
    1108           0 :                 pClone = pPage->GetObj(i);
    1109           0 :                 SdrObject* pCloneOfClone = pClone->Clone();
    1110             :                 //SdrObject* pCloneOfClone = pPage->GetObj(i)->Clone();
    1111           0 :                 pObjList->InsertObject(pCloneOfClone);
    1112             :             }
    1113             : 
    1114             :             // until now the top left corner of the group is in the window center;
    1115             :             // correct the position by half of the size of the group
    1116           0 :             aTemp = aMaxSizeLog;
    1117           0 :             aTemp.Height() = - aTemp.Height() / 2;
    1118           0 :             aTemp.Width()  = - aTemp.Width() / 2;
    1119           0 :             pGroup->NbcMove(aTemp);
    1120             : 
    1121             :             // #i42894# create needed SMIL stuff and move child objects to page directly (see
    1122             :             // comments at EffectMigration::CreateAnimatedGroup why this has to be done).
    1123           0 :             EffectMigration::CreateAnimatedGroup(*pGroup, *pTargetSdPage);
    1124             : 
    1125             :             // #i42894# if that worked, delete the group again
    1126           0 :             if(!pGroup->GetSubList()->GetObjCount())
    1127             :             {
    1128           0 :                 delete pGroup;
    1129             :             }
    1130             :         }
    1131             :     }
    1132             : 
    1133           0 :     ClickFirstHdl( this );
    1134           0 : }
    1135             : 
    1136           0 : void AnimationWindow::DataChanged( const DataChangedEvent& rDCEvt )
    1137             : {
    1138           0 :     SfxDockingWindow::DataChanged( rDCEvt );
    1139             : 
    1140           0 :     if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
    1141             :     {
    1142           0 :         UpdateControl();
    1143             :     }
    1144           0 : }
    1145             : 
    1146             : /**
    1147             :  * ControllerItem for Animator
    1148             :  */
    1149           0 : AnimationControllerItem::AnimationControllerItem(
    1150             :     sal_uInt16 _nId,
    1151             :     AnimationWindow* pAnimWin,
    1152             :     SfxBindings*    _pBindings)
    1153             :     : SfxControllerItem( _nId, *_pBindings ),
    1154           0 :       pAnimationWin( pAnimWin )
    1155             : {
    1156           0 : }
    1157             : 
    1158           0 : void AnimationControllerItem::StateChanged( sal_uInt16 nSId,
    1159             :                         SfxItemState eState, const SfxPoolItem* pItem )
    1160             : {
    1161           0 :     if( eState >= SfxItemState::DEFAULT && nSId == SID_ANIMATOR_STATE )
    1162             :     {
    1163           0 :         const SfxUInt16Item* pStateItem = PTR_CAST( SfxUInt16Item, pItem );
    1164             :         assert(pStateItem); //SfxUInt16Item expected
    1165           0 :         if (pStateItem)
    1166             :         {
    1167           0 :             sal_uInt16 nState = pStateItem->GetValue();
    1168           0 :             pAnimationWin->m_pBtnGetOneObject->Enable( nState & 1 );
    1169           0 :             pAnimationWin->m_pBtnGetAllObjects->Enable( nState & 2 );
    1170             :         }
    1171             :     }
    1172           0 : }
    1173             : 
    1174          66 : } // end of namespace sd
    1175             : 
    1176             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11