From 18651dbc32a2d58191c81d738a765a1c83546e12 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sat, 27 Apr 2019 14:20:10 +0900 Subject: rename animate.hxx to animate/Animation.hxx, more changes follow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the first step of refactoring Animation where it is needed to separate AnimationBitmap(s) from the Animation class, which is also responsible for displaying of animation. General idea is to make Graphic work only with AnimationBitmaps, which can be freely be swapped out and in, make copies - all transparantly from the actually displaying them and possibly it will also remove the need to copy the animation objects. Change-Id: If5d55ac1a5b26c3880d4f7602be57742b086f9da Reviewed-on: https://gerrit.libreoffice.org/71406 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- accessibility/inc/pch/precompiled_acc.hxx | 2 +- basctl/inc/pch/precompiled_basctl.hxx | 2 +- chart2/inc/pch/precompiled_chartcontroller.hxx | 2 +- cppcanvas/inc/pch/precompiled_cppcanvas.hxx | 2 +- cui/inc/pch/precompiled_cui.hxx | 2 +- dbaccess/inc/pch/precompiled_dba.hxx | 2 +- dbaccess/inc/pch/precompiled_dbmm.hxx | 2 +- desktop/inc/pch/precompiled_sofficeapp.hxx | 2 +- .../primitive2d/graphicprimitivehelper2d.cxx | 2 +- filter/source/graphicfilter/ieps/ieps.cxx | 2 +- filter/source/graphicfilter/itiff/itiff.cxx | 2 +- framework/inc/pch/precompiled_fwe.hxx | 2 +- framework/inc/pch/precompiled_fwk.hxx | 2 +- framework/inc/pch/precompiled_fwl.hxx | 2 +- include/svx/bmpmask.hxx | 2 +- include/vcl/animate.hxx | 188 ------ include/vcl/animate/Animation.hxx | 188 ++++++ include/vcl/graph.hxx | 2 +- oox/inc/pch/precompiled_oox.hxx | 2 +- reportdesign/inc/pch/precompiled_rpt.hxx | 2 +- reportdesign/inc/pch/precompiled_rptui.hxx | 2 +- sc/inc/pch/precompiled_sc.hxx | 2 +- sc/inc/pch/precompiled_scfilt.hxx | 2 +- sd/inc/pch/precompiled_sdui.hxx | 2 +- slideshow/inc/pch/precompiled_slideshow.hxx | 2 +- slideshow/source/engine/shapes/gdimtftools.cxx | 2 +- solenv/clang-format/blacklist | 4 +- svx/inc/pch/precompiled_svxcore.hxx | 2 +- sw/inc/pch/precompiled_msword.hxx | 2 +- sw/inc/pch/precompiled_swui.hxx | 2 +- sw/inc/pch/precompiled_vbaswobj.hxx | 2 +- vbahelper/inc/pch/precompiled_msforms.hxx | 2 +- vcl/Library_vcl.mk | 2 +- vcl/inc/graphic/Manager.hxx | 2 +- vcl/inc/impanmvw.hxx | 2 +- vcl/source/animate/Animation.cxx | 744 +++++++++++++++++++++ vcl/source/bitmap/bitmapfilter.cxx | 2 +- vcl/source/gdi/animate.cxx | 744 --------------------- vcl/source/graphic/GraphicObject2.cxx | 2 +- 39 files changed, 968 insertions(+), 968 deletions(-) delete mode 100644 include/vcl/animate.hxx create mode 100644 include/vcl/animate/Animation.hxx create mode 100644 vcl/source/animate/Animation.cxx delete mode 100644 vcl/source/gdi/animate.cxx diff --git a/accessibility/inc/pch/precompiled_acc.hxx b/accessibility/inc/pch/precompiled_acc.hxx index bfcd9876a129..1b1987ca5d8b 100644 --- a/accessibility/inc/pch/precompiled_acc.hxx +++ b/accessibility/inc/pch/precompiled_acc.hxx @@ -103,7 +103,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/basctl/inc/pch/precompiled_basctl.hxx b/basctl/inc/pch/precompiled_basctl.hxx index 2bce4900e2d7..df2e158ef096 100644 --- a/basctl/inc/pch/precompiled_basctl.hxx +++ b/basctl/inc/pch/precompiled_basctl.hxx @@ -114,7 +114,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/chart2/inc/pch/precompiled_chartcontroller.hxx b/chart2/inc/pch/precompiled_chartcontroller.hxx index d74343b59568..3e97c8ca8474 100644 --- a/chart2/inc/pch/precompiled_chartcontroller.hxx +++ b/chart2/inc/pch/precompiled_chartcontroller.hxx @@ -107,7 +107,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/cppcanvas/inc/pch/precompiled_cppcanvas.hxx b/cppcanvas/inc/pch/precompiled_cppcanvas.hxx index 491ee18fb1c7..6b41750c2ba3 100644 --- a/cppcanvas/inc/pch/precompiled_cppcanvas.hxx +++ b/cppcanvas/inc/pch/precompiled_cppcanvas.hxx @@ -81,7 +81,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/cui/inc/pch/precompiled_cui.hxx b/cui/inc/pch/precompiled_cui.hxx index 260b3a3350b9..d3e078be0c84 100644 --- a/cui/inc/pch/precompiled_cui.hxx +++ b/cui/inc/pch/precompiled_cui.hxx @@ -113,7 +113,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/dbaccess/inc/pch/precompiled_dba.hxx b/dbaccess/inc/pch/precompiled_dba.hxx index 9e39d3b10338..4b88a4c30ded 100644 --- a/dbaccess/inc/pch/precompiled_dba.hxx +++ b/dbaccess/inc/pch/precompiled_dba.hxx @@ -103,7 +103,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/dbaccess/inc/pch/precompiled_dbmm.hxx b/dbaccess/inc/pch/precompiled_dbmm.hxx index dc580df57f57..398c0b8dd853 100644 --- a/dbaccess/inc/pch/precompiled_dbmm.hxx +++ b/dbaccess/inc/pch/precompiled_dbmm.hxx @@ -90,7 +90,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/desktop/inc/pch/precompiled_sofficeapp.hxx b/desktop/inc/pch/precompiled_sofficeapp.hxx index ac170ca3b966..ccc4286c8dcc 100644 --- a/desktop/inc/pch/precompiled_sofficeapp.hxx +++ b/desktop/inc/pch/precompiled_sofficeapp.hxx @@ -111,7 +111,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx index bdedee85417b..5ad8ad359c0c 100644 --- a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx @@ -36,7 +36,7 @@ // helper class for animated graphics -#include +#include #include #include #include diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx index 3092bd51155c..c4e43e0fc7f2 100644 --- a/filter/source/graphicfilter/ieps/ieps.cxx +++ b/filter/source/graphicfilter/ieps/ieps.cxx @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/filter/source/graphicfilter/itiff/itiff.cxx b/filter/source/graphicfilter/itiff/itiff.cxx index 85dc9d297265..956efdbb4f6c 100644 --- a/filter/source/graphicfilter/itiff/itiff.cxx +++ b/filter/source/graphicfilter/itiff/itiff.cxx @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include "lzwdecom.hxx" diff --git a/framework/inc/pch/precompiled_fwe.hxx b/framework/inc/pch/precompiled_fwe.hxx index 7cdb1caee827..fcba92bc88ad 100644 --- a/framework/inc/pch/precompiled_fwe.hxx +++ b/framework/inc/pch/precompiled_fwe.hxx @@ -97,7 +97,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/framework/inc/pch/precompiled_fwk.hxx b/framework/inc/pch/precompiled_fwk.hxx index bee2b17a6a84..8c869f020b7b 100644 --- a/framework/inc/pch/precompiled_fwk.hxx +++ b/framework/inc/pch/precompiled_fwk.hxx @@ -106,7 +106,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/framework/inc/pch/precompiled_fwl.hxx b/framework/inc/pch/precompiled_fwl.hxx index 1fa07d4c6f70..ca170528d9b2 100644 --- a/framework/inc/pch/precompiled_fwl.hxx +++ b/framework/inc/pch/precompiled_fwl.hxx @@ -109,7 +109,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/svx/bmpmask.hxx b/include/svx/bmpmask.hxx index 3c7387276835..6020133cd1e7 100644 --- a/include/svx/bmpmask.hxx +++ b/include/svx/bmpmask.hxx @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/vcl/animate.hxx b/include/vcl/animate.hxx deleted file mode 100644 index 98d1bb8a3b61..000000000000 --- a/include/vcl/animate.hxx +++ /dev/null @@ -1,188 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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 . - */ - -#ifndef INCLUDED_VCL_ANIMATE_HXX -#define INCLUDED_VCL_ANIMATE_HXX - -#include -#include -#include - -#define ANIMATION_TIMEOUT_ON_CLICK 2147483647L - -enum class Disposal -{ - Not, - Back, - Previous -}; - -struct VCL_DLLPUBLIC AnimationBitmap -{ - BitmapEx aBmpEx; - Point aPosPix; - Size aSizePix; - long nWait; - Disposal eDisposal; - bool bUserInput; - - AnimationBitmap() - : nWait(0) - , eDisposal(Disposal::Not) - , bUserInput(false) - {} - - AnimationBitmap( - const BitmapEx& rBmpEx, - const Point& rPosPix, - const Size& rSizePix, - long _nWait = 0, - Disposal _eDisposal = Disposal::Not - ) : - aBmpEx ( rBmpEx ), - aPosPix ( rPosPix ), - aSizePix ( rSizePix ), - nWait ( _nWait ), - eDisposal ( _eDisposal ), - bUserInput ( false ) - {} - - bool operator==( const AnimationBitmap& rAnimBmp ) const - { - return( rAnimBmp.aBmpEx == aBmpEx && - rAnimBmp.aPosPix == aPosPix && - rAnimBmp.aSizePix == aSizePix && - rAnimBmp.nWait == nWait && - rAnimBmp.eDisposal == eDisposal && - rAnimBmp.bUserInput == bUserInput ); - } - - bool operator!=( const AnimationBitmap& rAnimBmp ) const - { return !( *this == rAnimBmp ); } - - - BitmapChecksum GetChecksum() const; -}; - -class ImplAnimView; - -class VCL_DLLPUBLIC Animation -{ -public: - Animation(); - Animation( const Animation& rAnimation ); - ~Animation(); - - Animation& operator=( const Animation& rAnimation ); - bool operator==( const Animation& rAnimation ) const; - bool operator!=( const Animation& rAnimation ) const - { return !(*this==rAnimation); } - - void Clear(); - - bool Start( - OutputDevice* pOutDev, - const Point& rDestPt, - const Size& rDestSz, - long nExtraData, - OutputDevice* pFirstFrameOutDev); - - void Stop( OutputDevice* pOutDev = nullptr, long nExtraData = 0 ); - - void Draw( OutputDevice* pOutDev, const Point& rDestPt ) const; - void Draw( OutputDevice* pOutDev, const Point& rDestPt, const Size& rDestSz ) const; - - bool IsInAnimation() const { return mbIsInAnimation; } - bool IsTransparent() const; - - const Size& GetDisplaySizePixel() const { return maGlobalSize; } - void SetDisplaySizePixel( const Size& rSize ) { maGlobalSize = rSize; } - - const BitmapEx& GetBitmapEx() const { return maBitmapEx; } - void SetBitmapEx( const BitmapEx& rBmpEx ) { maBitmapEx = rBmpEx; } - - sal_uInt32 GetLoopCount() const { return mnLoopCount; } - void SetLoopCount(const sal_uInt32 nLoopCount); - void ResetLoopCount(); - - void SetNotifyHdl( const Link& rLink ) { maNotifyLink = rLink; } - const Link& GetNotifyHdl() const { return maNotifyLink; } - - std::vector< std::unique_ptr >& GetAnimationFrames() { return maList; } - size_t Count() const { return maList.size(); } - bool Insert( const AnimationBitmap& rAnimationBitmap ); - const AnimationBitmap& - Get( sal_uInt16 nAnimation ) const; - void Replace( const AnimationBitmap& rNewAnimationBmp, sal_uInt16 nAnimation ); - - sal_uLong GetSizeBytes() const; - BitmapChecksum GetChecksum() const; - -public: - - void Convert( BmpConversion eConversion ); - bool ReduceColors( sal_uInt16 nNewColorCount ); - - bool Invert(); - void Mirror( BmpMirrorFlags nMirrorFlags ); - void Adjust( - short nLuminancePercent, - short nContrastPercent, - short nChannelRPercent, - short nChannelGPercent, - short nChannelBPercent, - double fGamma = 1.0, - bool bInvert = false ); - - friend VCL_DLLPUBLIC SvStream& ReadAnimation( SvStream& rIStream, Animation& rAnimation ); - friend VCL_DLLPUBLIC SvStream& WriteAnimation( SvStream& rOStream, const Animation& rAnimation ); - -public: - - SAL_DLLPRIVATE static void - ImplIncAnimCount() { mnAnimCount++; } - SAL_DLLPRIVATE static void - ImplDecAnimCount() { mnAnimCount--; } - SAL_DLLPRIVATE sal_uLong - ImplGetCurPos() const { return mnPos; } - -private: - SAL_DLLPRIVATE static sal_uLong mnAnimCount; - - std::vector< std::unique_ptr > maList; - std::vector< std::unique_ptr > maViewList; - - Link maNotifyLink; - BitmapEx maBitmapEx; - Timer maTimer; - Size maGlobalSize; - sal_uInt32 mnLoopCount; - sal_uInt32 mnLoops; - size_t mnPos; - bool mbIsInAnimation; - bool mbLoopTerminated; - - SAL_DLLPRIVATE void ImplRestartTimer( sal_uLong nTimeout ); - DECL_DLLPRIVATE_LINK( ImplTimeoutHdl, Timer*, void ); - -}; - -#endif // INCLUDED_VCL_ANIMATE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/animate/Animation.hxx b/include/vcl/animate/Animation.hxx new file mode 100644 index 000000000000..8b40ddeaa71a --- /dev/null +++ b/include/vcl/animate/Animation.hxx @@ -0,0 +1,188 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#ifndef INCLUDED_VCL_ANIMATE_ANIMATION_HXX +#define INCLUDED_VCL_ANIMATE_ANIMATION_HXX + +#include +#include +#include + +#define ANIMATION_TIMEOUT_ON_CLICK 2147483647L + +enum class Disposal +{ + Not, + Back, + Previous +}; + +struct VCL_DLLPUBLIC AnimationBitmap +{ + BitmapEx aBmpEx; + Point aPosPix; + Size aSizePix; + long nWait; + Disposal eDisposal; + bool bUserInput; + + AnimationBitmap() + : nWait(0) + , eDisposal(Disposal::Not) + , bUserInput(false) + {} + + AnimationBitmap( + const BitmapEx& rBmpEx, + const Point& rPosPix, + const Size& rSizePix, + long _nWait = 0, + Disposal _eDisposal = Disposal::Not + ) : + aBmpEx ( rBmpEx ), + aPosPix ( rPosPix ), + aSizePix ( rSizePix ), + nWait ( _nWait ), + eDisposal ( _eDisposal ), + bUserInput ( false ) + {} + + bool operator==( const AnimationBitmap& rAnimBmp ) const + { + return( rAnimBmp.aBmpEx == aBmpEx && + rAnimBmp.aPosPix == aPosPix && + rAnimBmp.aSizePix == aSizePix && + rAnimBmp.nWait == nWait && + rAnimBmp.eDisposal == eDisposal && + rAnimBmp.bUserInput == bUserInput ); + } + + bool operator!=( const AnimationBitmap& rAnimBmp ) const + { return !( *this == rAnimBmp ); } + + + BitmapChecksum GetChecksum() const; +}; + +class ImplAnimView; + +class VCL_DLLPUBLIC Animation +{ +public: + Animation(); + Animation( const Animation& rAnimation ); + ~Animation(); + + Animation& operator=( const Animation& rAnimation ); + bool operator==( const Animation& rAnimation ) const; + bool operator!=( const Animation& rAnimation ) const + { return !(*this==rAnimation); } + + void Clear(); + + bool Start( + OutputDevice* pOutDev, + const Point& rDestPt, + const Size& rDestSz, + long nExtraData, + OutputDevice* pFirstFrameOutDev); + + void Stop( OutputDevice* pOutDev = nullptr, long nExtraData = 0 ); + + void Draw( OutputDevice* pOutDev, const Point& rDestPt ) const; + void Draw( OutputDevice* pOutDev, const Point& rDestPt, const Size& rDestSz ) const; + + bool IsInAnimation() const { return mbIsInAnimation; } + bool IsTransparent() const; + + const Size& GetDisplaySizePixel() const { return maGlobalSize; } + void SetDisplaySizePixel( const Size& rSize ) { maGlobalSize = rSize; } + + const BitmapEx& GetBitmapEx() const { return maBitmapEx; } + void SetBitmapEx( const BitmapEx& rBmpEx ) { maBitmapEx = rBmpEx; } + + sal_uInt32 GetLoopCount() const { return mnLoopCount; } + void SetLoopCount(const sal_uInt32 nLoopCount); + void ResetLoopCount(); + + void SetNotifyHdl( const Link& rLink ) { maNotifyLink = rLink; } + const Link& GetNotifyHdl() const { return maNotifyLink; } + + std::vector< std::unique_ptr >& GetAnimationFrames() { return maList; } + size_t Count() const { return maList.size(); } + bool Insert( const AnimationBitmap& rAnimationBitmap ); + const AnimationBitmap& + Get( sal_uInt16 nAnimation ) const; + void Replace( const AnimationBitmap& rNewAnimationBmp, sal_uInt16 nAnimation ); + + sal_uLong GetSizeBytes() const; + BitmapChecksum GetChecksum() const; + +public: + + void Convert( BmpConversion eConversion ); + bool ReduceColors( sal_uInt16 nNewColorCount ); + + bool Invert(); + void Mirror( BmpMirrorFlags nMirrorFlags ); + void Adjust( + short nLuminancePercent, + short nContrastPercent, + short nChannelRPercent, + short nChannelGPercent, + short nChannelBPercent, + double fGamma = 1.0, + bool bInvert = false ); + + friend VCL_DLLPUBLIC SvStream& ReadAnimation( SvStream& rIStream, Animation& rAnimation ); + friend VCL_DLLPUBLIC SvStream& WriteAnimation( SvStream& rOStream, const Animation& rAnimation ); + +public: + + SAL_DLLPRIVATE static void + ImplIncAnimCount() { mnAnimCount++; } + SAL_DLLPRIVATE static void + ImplDecAnimCount() { mnAnimCount--; } + SAL_DLLPRIVATE sal_uLong + ImplGetCurPos() const { return mnPos; } + +private: + SAL_DLLPRIVATE static sal_uLong mnAnimCount; + + std::vector< std::unique_ptr > maList; + std::vector< std::unique_ptr > maViewList; + + Link maNotifyLink; + BitmapEx maBitmapEx; + Timer maTimer; + Size maGlobalSize; + sal_uInt32 mnLoopCount; + sal_uInt32 mnLoops; + size_t mnPos; + bool mbIsInAnimation; + bool mbLoopTerminated; + + SAL_DLLPRIVATE void ImplRestartTimer( sal_uLong nTimeout ); + DECL_DLLPRIVATE_LINK( ImplTimeoutHdl, Timer*, void ); + +}; + +#endif // INCLUDED_VCL_ANIMATE_ANIMATION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx index 3b3e280ebd8c..f44858c88085 100644 --- a/include/vcl/graph.hxx +++ b/include/vcl/graph.hxx @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/oox/inc/pch/precompiled_oox.hxx b/oox/inc/pch/precompiled_oox.hxx index 222e9663fca5..d65aa127e897 100644 --- a/oox/inc/pch/precompiled_oox.hxx +++ b/oox/inc/pch/precompiled_oox.hxx @@ -79,7 +79,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/reportdesign/inc/pch/precompiled_rpt.hxx b/reportdesign/inc/pch/precompiled_rpt.hxx index a19aa62d789d..2bb4eaefee66 100644 --- a/reportdesign/inc/pch/precompiled_rpt.hxx +++ b/reportdesign/inc/pch/precompiled_rpt.hxx @@ -111,7 +111,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/reportdesign/inc/pch/precompiled_rptui.hxx b/reportdesign/inc/pch/precompiled_rptui.hxx index 92e0fe824920..ef65b5741392 100644 --- a/reportdesign/inc/pch/precompiled_rptui.hxx +++ b/reportdesign/inc/pch/precompiled_rptui.hxx @@ -117,7 +117,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sc/inc/pch/precompiled_sc.hxx b/sc/inc/pch/precompiled_sc.hxx index 67f567be8246..383739b80643 100644 --- a/sc/inc/pch/precompiled_sc.hxx +++ b/sc/inc/pch/precompiled_sc.hxx @@ -118,7 +118,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sc/inc/pch/precompiled_scfilt.hxx b/sc/inc/pch/precompiled_scfilt.hxx index 296250160562..7bdab2f9da53 100644 --- a/sc/inc/pch/precompiled_scfilt.hxx +++ b/sc/inc/pch/precompiled_scfilt.hxx @@ -89,7 +89,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sd/inc/pch/precompiled_sdui.hxx b/sd/inc/pch/precompiled_sdui.hxx index 1a323669d41d..41a9a2dff3e2 100644 --- a/sd/inc/pch/precompiled_sdui.hxx +++ b/sd/inc/pch/precompiled_sdui.hxx @@ -115,7 +115,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/slideshow/inc/pch/precompiled_slideshow.hxx b/slideshow/inc/pch/precompiled_slideshow.hxx index e12d6dcafa9f..564dc175ce26 100644 --- a/slideshow/inc/pch/precompiled_slideshow.hxx +++ b/slideshow/inc/pch/precompiled_slideshow.hxx @@ -101,7 +101,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/slideshow/source/engine/shapes/gdimtftools.cxx b/slideshow/source/engine/shapes/gdimtftools.cxx index 3221a1069931..ef9f4df82aee 100644 --- a/slideshow/source/engine/shapes/gdimtftools.cxx +++ b/slideshow/source/engine/shapes/gdimtftools.cxx @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist index 096cbea75ecc..f5a19345265e 100644 --- a/solenv/clang-format/blacklist +++ b/solenv/clang-format/blacklist @@ -7809,7 +7809,7 @@ include/vcl/accessiblefactory.hxx include/vcl/accessibletable.hxx include/vcl/accessibletableprovider.hxx include/vcl/alpha.hxx -include/vcl/animate.hxx +include/vcl/animate/Animation.hxx include/vcl/bitmap.hxx include/vcl/bitmapaccess.hxx include/vcl/bitmapex.hxx @@ -17756,6 +17756,7 @@ vcl/quartz/salgdicommon.cxx vcl/quartz/salgdiutils.cxx vcl/quartz/salvd.cxx vcl/quartz/utils.cxx +vcl/source/animate/Animation.cxx vcl/source/app/ITiledRenderable.cxx vcl/source/app/IconThemeInfo.cxx vcl/source/app/IconThemeScanner.cxx @@ -17892,7 +17893,6 @@ vcl/source/fontsubset/xlat.hxx vcl/source/gdi/CommonSalLayout.cxx vcl/source/gdi/VerticalOrientationData.cxx vcl/source/gdi/alpha.cxx -vcl/source/gdi/animate.cxx vcl/source/gdi/bitmap3.cxx vcl/source/gdi/bitmapex.cxx vcl/source/gdi/bmpacc.cxx diff --git a/svx/inc/pch/precompiled_svxcore.hxx b/svx/inc/pch/precompiled_svxcore.hxx index 2532dc732f66..f69e7facbdf4 100644 --- a/svx/inc/pch/precompiled_svxcore.hxx +++ b/svx/inc/pch/precompiled_svxcore.hxx @@ -106,7 +106,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/inc/pch/precompiled_msword.hxx b/sw/inc/pch/precompiled_msword.hxx index 8635a2062a7d..b2567272dddf 100644 --- a/sw/inc/pch/precompiled_msword.hxx +++ b/sw/inc/pch/precompiled_msword.hxx @@ -115,7 +115,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/inc/pch/precompiled_swui.hxx b/sw/inc/pch/precompiled_swui.hxx index f78a904d287d..cf3f92c8050b 100644 --- a/sw/inc/pch/precompiled_swui.hxx +++ b/sw/inc/pch/precompiled_swui.hxx @@ -120,7 +120,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/inc/pch/precompiled_vbaswobj.hxx b/sw/inc/pch/precompiled_vbaswobj.hxx index 14c103107a75..c7a23a64cc66 100644 --- a/sw/inc/pch/precompiled_vbaswobj.hxx +++ b/sw/inc/pch/precompiled_vbaswobj.hxx @@ -121,7 +121,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/vbahelper/inc/pch/precompiled_msforms.hxx b/vbahelper/inc/pch/precompiled_msforms.hxx index 36752910cc83..bcb826e7a892 100644 --- a/vbahelper/inc/pch/precompiled_msforms.hxx +++ b/vbahelper/inc/pch/precompiled_msforms.hxx @@ -93,7 +93,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 1ebdafdf6b18..b66da1f8a071 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -115,6 +115,7 @@ $(eval $(call gb_Library_use_externals,vcl,\ endif $(eval $(call gb_Library_add_exception_objects,vcl,\ + vcl/source/animate/Animation \ vcl/source/window/errinf \ vcl/source/window/settings \ vcl/source/window/paint \ @@ -248,7 +249,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/treelist/svlbitm \ vcl/source/treelist/uiobject \ vcl/source/gdi/alpha \ - vcl/source/gdi/animate \ vcl/source/gdi/bitmap3 \ vcl/source/gdi/bitmapex \ vcl/source/gdi/bmpacc2 \ diff --git a/vcl/inc/graphic/Manager.hxx b/vcl/inc/graphic/Manager.hxx index 1f897ecf7146..d6c0d718f8af 100644 --- a/vcl/inc/graphic/Manager.hxx +++ b/vcl/inc/graphic/Manager.hxx @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/vcl/inc/impanmvw.hxx b/vcl/inc/impanmvw.hxx index b8164f60933d..95aafb1001a4 100644 --- a/vcl/inc/impanmvw.hxx +++ b/vcl/inc/impanmvw.hxx @@ -20,7 +20,7 @@ #ifndef INCLUDED_VCL_SOURCE_GDI_IMPANMVW_HXX #define INCLUDED_VCL_SOURCE_GDI_IMPANMVW_HXX -#include +#include #include class Animation; diff --git a/vcl/source/animate/Animation.cxx b/vcl/source/animate/Animation.cxx new file mode 100644 index 000000000000..3e3f20b551b0 --- /dev/null +++ b/vcl/source/animate/Animation.cxx @@ -0,0 +1,744 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 . + */ + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#define MIN_TIMEOUT 2 + +sal_uLong Animation::mnAnimCount = 0; + +BitmapChecksum AnimationBitmap::GetChecksum() const +{ + BitmapChecksum nCrc = aBmpEx.GetChecksum(); + SVBT32 aBT32; + + Int32ToSVBT32( aPosPix.X(), aBT32 ); + nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + + Int32ToSVBT32( aPosPix.Y(), aBT32 ); + nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + + Int32ToSVBT32( aSizePix.Width(), aBT32 ); + nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + + Int32ToSVBT32( aSizePix.Height(), aBT32 ); + nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + + Int32ToSVBT32( nWait, aBT32 ); + nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + + UInt32ToSVBT32( o3tl::underlyingEnumValue(eDisposal), aBT32 ); + nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + + UInt32ToSVBT32( sal_uInt32(bUserInput), aBT32 ); + nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + + return nCrc; +} + +Animation::Animation() : + mnLoopCount ( 0 ), + mnLoops ( 0 ), + mnPos ( 0 ), + mbIsInAnimation ( false ), + mbLoopTerminated ( false ) +{ + maTimer.SetInvokeHandler( LINK( this, Animation, ImplTimeoutHdl ) ); +} + +Animation::Animation( const Animation& rAnimation ) : + maBitmapEx ( rAnimation.maBitmapEx ), + maGlobalSize ( rAnimation.maGlobalSize ), + mnLoopCount ( rAnimation.mnLoopCount ), + mnPos ( rAnimation.mnPos ), + mbIsInAnimation ( false ), + mbLoopTerminated ( rAnimation.mbLoopTerminated ) +{ + + for(auto const & i : rAnimation.maList) + maList.emplace_back( new AnimationBitmap( *i ) ); + + maTimer.SetInvokeHandler( LINK( this, Animation, ImplTimeoutHdl ) ); + mnLoops = mbLoopTerminated ? 0 : mnLoopCount; +} + +Animation::~Animation() +{ + if( mbIsInAnimation ) + Stop(); +} + +Animation& Animation::operator=( const Animation& rAnimation ) +{ + if (this != &rAnimation) + { + Clear(); + + for(auto const & i : rAnimation.maList) + maList.emplace_back( new AnimationBitmap( *i ) ); + + maGlobalSize = rAnimation.maGlobalSize; + maBitmapEx = rAnimation.maBitmapEx; + mnLoopCount = rAnimation.mnLoopCount; + mnPos = rAnimation.mnPos; + mbLoopTerminated = rAnimation.mbLoopTerminated; + mnLoops = mbLoopTerminated ? 0 : mnLoopCount; + } + return *this; +} + +bool Animation::operator==( const Animation& rAnimation ) const +{ + const size_t nCount = maList.size(); + bool bRet = false; + + if( rAnimation.maList.size() == nCount + && rAnimation.maBitmapEx == maBitmapEx + && rAnimation.maGlobalSize == maGlobalSize + ) + { + bRet = true; + + for( size_t n = 0; n < nCount; n++ ) + { + if( ( *maList[ n ] ) != ( *rAnimation.maList[ n ] ) ) + { + bRet = false; + break; + } + } + } + + return bRet; +} + +void Animation::Clear() +{ + maTimer.Stop(); + mbIsInAnimation = false; + maGlobalSize = Size(); + maBitmapEx.SetEmpty(); + maList.clear(); + maViewList.clear(); +} + +bool Animation::IsTransparent() const +{ + tools::Rectangle aRect( Point(), maGlobalSize ); + bool bRet = false; + + // If some small bitmap needs to be replaced by the background, + // we need to be transparent, in order to be displayed correctly + // as the application (?) does not invalidate on non-transparent + // graphics due to performance reasons. + for(auto const & pAnimBmp : maList) + { + if( Disposal::Back == pAnimBmp->eDisposal + && tools::Rectangle( pAnimBmp->aPosPix, pAnimBmp->aSizePix ) != aRect + ) + { + bRet = true; + break; + } + } + + if( !bRet ) + bRet = maBitmapEx.IsTransparent(); + + return bRet; +} + +sal_uLong Animation::GetSizeBytes() const +{ + sal_uLong nSizeBytes = GetBitmapEx().GetSizeBytes(); + + for(auto const & pAnimBmp : maList) + { + nSizeBytes += pAnimBmp->aBmpEx.GetSizeBytes(); + } + + return nSizeBytes; +} + +BitmapChecksum Animation::GetChecksum() const +{ + SVBT32 aBT32; + BitmapChecksumOctetArray aBCOA; + BitmapChecksum nCrc = GetBitmapEx().GetChecksum(); + + UInt32ToSVBT32( maList.size(), aBT32 ); + nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + + Int32ToSVBT32( maGlobalSize.Width(), aBT32 ); + nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + + Int32ToSVBT32( maGlobalSize.Height(), aBT32 ); + nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); + + for(auto const & i : maList) + { + BCToBCOA( i->GetChecksum(), aBCOA ); + nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); + } + + return nCrc; +} + +bool Animation::Start( OutputDevice* pOut, const Point& rDestPt, const Size& rDestSz, long nExtraData, + OutputDevice* pFirstFrameOutDev ) +{ + bool bRet = false; + + if( !maList.empty() ) + { + if( ( pOut->GetOutDevType() == OUTDEV_WINDOW ) + && !mbLoopTerminated + && ( ANIMATION_TIMEOUT_ON_CLICK != maList[ mnPos ]->nWait ) + ) + { + ImplAnimView* pView; + ImplAnimView* pMatch = nullptr; + + for( size_t i = 0; i < maViewList.size(); ++i ) + { + pView = maViewList[ i ].get(); + if( pView->matches( pOut, nExtraData ) ) + { + if( pView->getOutPos() == rDestPt && + pView->getOutSizePix() == pOut->LogicToPixel( rDestSz ) ) + { + pView->repaint(); + pMatch = pView; + } + else + { + maViewList.erase( maViewList.begin() + i ); + pView = nullptr; + } + + break; + } + } + + if( maViewList.empty() ) + { + maTimer.Stop(); + mbIsInAnimation = false; + mnPos = 0; + } + + if( !pMatch ) + maViewList.emplace_back( new ImplAnimView( this, pOut, rDestPt, rDestSz, nExtraData, pFirstFrameOutDev ) ); + + if( !mbIsInAnimation ) + { + ImplRestartTimer( maList[ mnPos ]->nWait ); + mbIsInAnimation = true; + } + } + else + Draw( pOut, rDestPt, rDestSz ); + + bRet = true; + } + + return bRet; +} + +void Animation::Stop( OutputDevice* pOut, long nExtraData ) +{ + for( size_t i = 0; i < maViewList.size(); ) + { + ImplAnimView* pView = maViewList[ i ].get(); + if( pView->matches( pOut, nExtraData ) ) + { + maViewList.erase( maViewList.begin() + i ); + } + else + i++; + } + + if( maViewList.empty() ) + { + maTimer.Stop(); + mbIsInAnimation = false; + } +} + +void Animation::Draw( OutputDevice* pOut, const Point& rDestPt ) const +{ + Draw( pOut, rDestPt, pOut->PixelToLogic( maGlobalSize ) ); +} + +void Animation::Draw( OutputDevice* pOut, const Point& rDestPt, const Size& rDestSz ) const +{ + const size_t nCount = maList.size(); + + if( nCount ) + { + AnimationBitmap* pObj = maList[ std::min( mnPos, nCount - 1 ) ].get(); + + if( pOut->GetConnectMetaFile() + || ( pOut->GetOutDevType() == OUTDEV_PRINTER ) + ) + maList[ 0 ]->aBmpEx.Draw( pOut, rDestPt, rDestSz ); + else if( ANIMATION_TIMEOUT_ON_CLICK == pObj->nWait ) + pObj->aBmpEx.Draw( pOut, rDestPt, rDestSz ); + else + { + const size_t nOldPos = mnPos; + const_cast(this)->mnPos = mbLoopTerminated ? ( nCount - 1 ) : mnPos; + delete new ImplAnimView( const_cast(this), pOut, rDestPt, rDestSz, 0 ); + const_cast(this)->mnPos = nOldPos; + } + } +} + +void Animation::ImplRestartTimer( sal_uLong nTimeout ) +{ + maTimer.SetTimeout( std::max( nTimeout, static_cast(MIN_TIMEOUT) ) * 10 ); + maTimer.Start(); +} + +IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer *, void) +{ + const size_t nAnimCount = maList.size(); + + if( nAnimCount ) + { + ImplAnimView* pView; + bool bGlobalPause = true; + + if( maNotifyLink.IsSet() ) + { + std::vector< std::unique_ptr > aAInfoList; + // create AInfo-List + for(auto const & i : maViewList) + aAInfoList.emplace_back( i->createAInfo() ); + + maNotifyLink.Call( this ); + + // set view state from AInfo structure + for(auto& pAInfo : aAInfoList) + { + if( !pAInfo->pViewData ) + { + pView = new ImplAnimView( this, pAInfo->pOutDev, + pAInfo->aStartOrg, pAInfo->aStartSize, pAInfo->nExtraData ); + + maViewList.push_back( std::unique_ptr(pView) ); + } + else + pView = static_cast(pAInfo->pViewData); + + pView->pause( pAInfo->bPause ); + pView->setMarked( true ); + } + + // delete all unmarked views and reset marked state + for( size_t i = 0; i < maViewList.size(); ) + { + pView = maViewList[ i ].get(); + if( !pView->isMarked() ) + { + maViewList.erase( maViewList.begin() + i ); + } + else + { + if( !pView->isPause() ) + bGlobalPause = false; + + pView->setMarked( false ); + i++; + } + } + } + else + bGlobalPause = false; + + if( maViewList.empty() ) + Stop(); + else if( bGlobalPause ) + ImplRestartTimer( 10 ); + else + { + AnimationBitmap* pStepBmp = (++mnPos < maList.size()) ? maList[ mnPos ].get() : nullptr; + + if( !pStepBmp ) + { + if( mnLoops == 1 ) + { + Stop(); + mbLoopTerminated = true; + mnPos = nAnimCount - 1; + maBitmapEx = maList[ mnPos ]->aBmpEx; + return; + } + else + { + if( mnLoops ) + mnLoops--; + + mnPos = 0; + pStepBmp = maList[ mnPos ].get(); + } + } + + // Paint all views; after painting check, if view is + // marked; in this case remove view, because area of output + // lies out of display area of window; mark state is + // set from view itself + for( size_t i = 0; i < maViewList.size(); ) + { + pView = maViewList[ i ].get(); + pView->draw( mnPos ); + + if( pView->isMarked() ) + { + maViewList.erase( maViewList.begin() + i ); + } + else + i++; + } + + // stop or restart timer + if( maViewList.empty() ) + Stop(); + else + ImplRestartTimer( pStepBmp->nWait ); + } + } + else + Stop(); +} + +bool Animation::Insert( const AnimationBitmap& rStepBmp ) +{ + bool bRet = false; + + if( !IsInAnimation() ) + { + tools::Rectangle aGlobalRect( Point(), maGlobalSize ); + + maGlobalSize = aGlobalRect.Union( tools::Rectangle( rStepBmp.aPosPix, rStepBmp.aSizePix ) ).GetSize(); + maList.emplace_back( new AnimationBitmap( rStepBmp ) ); + + // As a start, we make the first BitmapEx the replacement BitmapEx + if( maList.size() == 1 ) + maBitmapEx = rStepBmp.aBmpEx; + + bRet = true; + } + + return bRet; +} + +const AnimationBitmap& Animation::Get( sal_uInt16 nAnimation ) const +{ + SAL_WARN_IF( ( nAnimation >= maList.size() ), "vcl", "No object at this position" ); + return *maList[ nAnimation ]; +} + +void Animation::Replace( const AnimationBitmap& rNewAnimationBitmap, sal_uInt16 nAnimation ) +{ + SAL_WARN_IF( ( nAnimation >= maList.size() ), "vcl", "No object at this position" ); + + maList[ nAnimation ].reset( new AnimationBitmap( rNewAnimationBitmap ) ); + + // If we insert at first position we also need to + // update the replacement BitmapEx + if ( ( !nAnimation + && ( !mbLoopTerminated + || ( maList.size() == 1 ) + ) + ) + || + ( ( nAnimation == maList.size() - 1 ) + && mbLoopTerminated + ) + ) + { + maBitmapEx = rNewAnimationBitmap.aBmpEx; + } +} + +void Animation::SetLoopCount(const sal_uInt32 nLoopCount) +{ + mnLoopCount = nLoopCount; + ResetLoopCount(); +} + +void Animation::ResetLoopCount() +{ + mnLoops = mnLoopCount; + mbLoopTerminated = false; +} + +void Animation::Convert( BmpConversion eConversion ) +{ + SAL_WARN_IF( IsInAnimation(), "vcl", "Animation modified while it is animated" ); + + bool bRet; + + if( !IsInAnimation() && !maList.empty() ) + { + bRet = true; + + for( size_t i = 0, n = maList.size(); ( i < n ) && bRet; ++i ) + bRet = maList[ i ]->aBmpEx.Convert( eConversion ); + + maBitmapEx.Convert( eConversion ); + } +} + +bool Animation::ReduceColors( sal_uInt16 nNewColorCount ) +{ + SAL_WARN_IF( IsInAnimation(), "vcl", "Animation modified while it is animated" ); + + bool bRet; + + if( !IsInAnimation() && !maList.empty() ) + { + bRet = true; + + for (size_t i = 0, n = maList.size(); (i < n) && bRet; ++i) + { + bRet = BitmapFilter::Filter(maList[i]->aBmpEx, BitmapColorQuantizationFilter(nNewColorCount)); + } + + BitmapFilter::Filter(maBitmapEx, BitmapColorQuantizationFilter(nNewColorCount)); + } + else + { + bRet = false; + } + + return bRet; +} + +bool Animation::Invert() +{ + SAL_WARN_IF( IsInAnimation(), "vcl", "Animation modified while it is animated" ); + + bool bRet; + + if( !IsInAnimation() && !maList.empty() ) + { + bRet = true; + + for( size_t i = 0, n = maList.size(); ( i < n ) && bRet; ++i ) + bRet = maList[ i ]->aBmpEx.Invert(); + + maBitmapEx.Invert(); + } + else + bRet = false; + + return bRet; +} + +void Animation::Mirror( BmpMirrorFlags nMirrorFlags ) +{ + SAL_WARN_IF( IsInAnimation(), "vcl", "Animation modified while it is animated" ); + + bool bRet; + + if( !IsInAnimation() && !maList.empty() ) + { + bRet = true; + + if( nMirrorFlags != BmpMirrorFlags::NONE ) + { + for( size_t i = 0, n = maList.size(); ( i < n ) && bRet; ++i ) + { + AnimationBitmap* pStepBmp = maList[ i ].get(); + bRet = pStepBmp->aBmpEx.Mirror( nMirrorFlags ); + if( bRet ) + { + if( nMirrorFlags & BmpMirrorFlags::Horizontal ) + pStepBmp->aPosPix.setX( maGlobalSize.Width() - pStepBmp->aPosPix.X() - pStepBmp->aSizePix.Width() ); + + if( nMirrorFlags & BmpMirrorFlags::Vertical ) + pStepBmp->aPosPix.setY( maGlobalSize.Height() - pStepBmp->aPosPix.Y() - pStepBmp->aSizePix.Height() ); + } + } + + maBitmapEx.Mirror( nMirrorFlags ); + } + } +} + +void Animation::Adjust( short nLuminancePercent, short nContrastPercent, + short nChannelRPercent, short nChannelGPercent, short nChannelBPercent, + double fGamma, bool bInvert ) +{ + SAL_WARN_IF( IsInAnimation(), "vcl", "Animation modified while it is animated" ); + + bool bRet; + + if( !IsInAnimation() && !maList.empty() ) + { + bRet = true; + + for( size_t i = 0, n = maList.size(); ( i < n ) && bRet; ++i ) + { + bRet = maList[ i ]->aBmpEx.Adjust( nLuminancePercent, + nContrastPercent, + nChannelRPercent, + nChannelGPercent, + nChannelBPercent, + fGamma, bInvert + ); + } + + maBitmapEx.Adjust( nLuminancePercent, nContrastPercent, + nChannelRPercent, nChannelGPercent, nChannelBPercent, + fGamma, bInvert ); + } +} + +SvStream& WriteAnimation( SvStream& rOStm, const Animation& rAnimation ) +{ + const sal_uInt16 nCount = rAnimation.Count(); + + if( nCount ) + { + const sal_uInt32 nDummy32 = 0; + + // If no BitmapEx was set we write the first Bitmap of + // the Animation + if( !rAnimation.GetBitmapEx().GetBitmap() ) + WriteDIBBitmapEx(rAnimation.Get( 0 ).aBmpEx, rOStm); + else + WriteDIBBitmapEx(rAnimation.GetBitmapEx(), rOStm); + + // Write identifier ( SDANIMA1 ) + rOStm.WriteUInt32( 0x5344414e ).WriteUInt32( 0x494d4931 ); + + for( sal_uInt16 i = 0; i < nCount; i++ ) + { + const AnimationBitmap& rAnimBmp = rAnimation.Get( i ); + const sal_uInt16 nRest = nCount - i - 1; + + // Write AnimationBitmap + WriteDIBBitmapEx(rAnimBmp.aBmpEx, rOStm); + WritePair( rOStm, rAnimBmp.aPosPix ); + WritePair( rOStm, rAnimBmp.aSizePix ); + WritePair( rOStm, rAnimation.maGlobalSize ); + rOStm.WriteUInt16( ( ANIMATION_TIMEOUT_ON_CLICK == rAnimBmp.nWait ) ? 65535 : rAnimBmp.nWait ); + rOStm.WriteUInt16( static_cast(rAnimBmp.eDisposal) ); + rOStm.WriteBool( rAnimBmp.bUserInput ); + rOStm.WriteUInt32( rAnimation.mnLoopCount ); + rOStm.WriteUInt32( nDummy32 ); // Unused + rOStm.WriteUInt32( nDummy32 ); // Unused + rOStm.WriteUInt32( nDummy32 ); // Unused + write_uInt16_lenPrefixed_uInt8s_FromOString(rOStm, OString()); // dummy + rOStm.WriteUInt16( nRest ); // Count of remaining structures + } + } + + return rOStm; +} + +SvStream& ReadAnimation( SvStream& rIStm, Animation& rAnimation ) +{ + sal_uLong nStmPos; + sal_uInt32 nAnimMagic1, nAnimMagic2; + SvStreamEndian nOldFormat = rIStm.GetEndian(); + bool bReadAnimations = false; + + rIStm.SetEndian( SvStreamEndian::LITTLE ); + nStmPos = rIStm.Tell(); + rIStm.ReadUInt32( nAnimMagic1 ).ReadUInt32( nAnimMagic2 ); + + rAnimation.Clear(); + + // If the BitmapEx at the beginning have already been read (by Graphic) + // we can start reading the AnimationBitmaps right away + if( ( nAnimMagic1 == 0x5344414e ) && ( nAnimMagic2 == 0x494d4931 ) && !rIStm.GetError() ) + bReadAnimations = true; + // Else, we try reading the Bitmap(-Ex) + else + { + rIStm.Seek( nStmPos ); + ReadDIBBitmapEx(rAnimation.maBitmapEx, rIStm); + nStmPos = rIStm.Tell(); + rIStm.ReadUInt32( nAnimMagic1 ).ReadUInt32( nAnimMagic2 ); + + if( ( nAnimMagic1 == 0x5344414e ) && ( nAnimMagic2 == 0x494d4931 ) && !rIStm.GetError() ) + bReadAnimations = true; + else + rIStm.Seek( nStmPos ); + } + + // Read AnimationBitmaps + if( bReadAnimations ) + { + AnimationBitmap aAnimBmp; + sal_uInt32 nTmp32; + sal_uInt16 nTmp16; + bool cTmp; + + do + { + ReadDIBBitmapEx(aAnimBmp.aBmpEx, rIStm); + ReadPair( rIStm, aAnimBmp.aPosPix ); + ReadPair( rIStm, aAnimBmp.aSizePix ); + ReadPair( rIStm, rAnimation.maGlobalSize ); + rIStm.ReadUInt16( nTmp16 ); aAnimBmp.nWait = ( ( 65535 == nTmp16 ) ? ANIMATION_TIMEOUT_ON_CLICK : nTmp16 ); + rIStm.ReadUInt16( nTmp16 ); aAnimBmp.eDisposal = static_cast(nTmp16); + rIStm.ReadCharAsBool( cTmp ); aAnimBmp.bUserInput = cTmp; + rIStm.ReadUInt32( rAnimation.mnLoopCount ); + rIStm.ReadUInt32( nTmp32 ); // Unused + rIStm.ReadUInt32( nTmp32 ); // Unused + rIStm.ReadUInt32( nTmp32 ); // Unused + read_uInt16_lenPrefixed_uInt8s_ToOString(rIStm); // Unused + rIStm.ReadUInt16( nTmp16 ); // The rest to read + + rAnimation.Insert( aAnimBmp ); + } + while( nTmp16 && !rIStm.GetError() ); + + rAnimation.ResetLoopCount(); + } + + rIStm.SetEndian( nOldFormat ); + + return rIStm; +} + +AInfo::AInfo() : pOutDev( nullptr ), + pViewData( nullptr ), + nExtraData( 0 ), + bPause( false ) {} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/bitmap/bitmapfilter.cxx b/vcl/source/bitmap/bitmapfilter.cxx index b28573cf3906..347cfd069a6a 100644 --- a/vcl/source/bitmap/bitmapfilter.cxx +++ b/vcl/source/bitmap/bitmapfilter.cxx @@ -9,7 +9,7 @@ */ #include -#include +#include #include #include diff --git a/vcl/source/gdi/animate.cxx b/vcl/source/gdi/animate.cxx deleted file mode 100644 index 25eceb595f39..000000000000 --- a/vcl/source/gdi/animate.cxx +++ /dev/null @@ -1,744 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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 . - */ - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#define MIN_TIMEOUT 2 - -sal_uLong Animation::mnAnimCount = 0; - -BitmapChecksum AnimationBitmap::GetChecksum() const -{ - BitmapChecksum nCrc = aBmpEx.GetChecksum(); - SVBT32 aBT32; - - Int32ToSVBT32( aPosPix.X(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( aPosPix.Y(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( aSizePix.Width(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( aSizePix.Height(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( nWait, aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - UInt32ToSVBT32( o3tl::underlyingEnumValue(eDisposal), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - UInt32ToSVBT32( sal_uInt32(bUserInput), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - return nCrc; -} - -Animation::Animation() : - mnLoopCount ( 0 ), - mnLoops ( 0 ), - mnPos ( 0 ), - mbIsInAnimation ( false ), - mbLoopTerminated ( false ) -{ - maTimer.SetInvokeHandler( LINK( this, Animation, ImplTimeoutHdl ) ); -} - -Animation::Animation( const Animation& rAnimation ) : - maBitmapEx ( rAnimation.maBitmapEx ), - maGlobalSize ( rAnimation.maGlobalSize ), - mnLoopCount ( rAnimation.mnLoopCount ), - mnPos ( rAnimation.mnPos ), - mbIsInAnimation ( false ), - mbLoopTerminated ( rAnimation.mbLoopTerminated ) -{ - - for(auto const & i : rAnimation.maList) - maList.emplace_back( new AnimationBitmap( *i ) ); - - maTimer.SetInvokeHandler( LINK( this, Animation, ImplTimeoutHdl ) ); - mnLoops = mbLoopTerminated ? 0 : mnLoopCount; -} - -Animation::~Animation() -{ - if( mbIsInAnimation ) - Stop(); -} - -Animation& Animation::operator=( const Animation& rAnimation ) -{ - if (this != &rAnimation) - { - Clear(); - - for(auto const & i : rAnimation.maList) - maList.emplace_back( new AnimationBitmap( *i ) ); - - maGlobalSize = rAnimation.maGlobalSize; - maBitmapEx = rAnimation.maBitmapEx; - mnLoopCount = rAnimation.mnLoopCount; - mnPos = rAnimation.mnPos; - mbLoopTerminated = rAnimation.mbLoopTerminated; - mnLoops = mbLoopTerminated ? 0 : mnLoopCount; - } - return *this; -} - -bool Animation::operator==( const Animation& rAnimation ) const -{ - const size_t nCount = maList.size(); - bool bRet = false; - - if( rAnimation.maList.size() == nCount - && rAnimation.maBitmapEx == maBitmapEx - && rAnimation.maGlobalSize == maGlobalSize - ) - { - bRet = true; - - for( size_t n = 0; n < nCount; n++ ) - { - if( ( *maList[ n ] ) != ( *rAnimation.maList[ n ] ) ) - { - bRet = false; - break; - } - } - } - - return bRet; -} - -void Animation::Clear() -{ - maTimer.Stop(); - mbIsInAnimation = false; - maGlobalSize = Size(); - maBitmapEx.SetEmpty(); - maList.clear(); - maViewList.clear(); -} - -bool Animation::IsTransparent() const -{ - tools::Rectangle aRect( Point(), maGlobalSize ); - bool bRet = false; - - // If some small bitmap needs to be replaced by the background, - // we need to be transparent, in order to be displayed correctly - // as the application (?) does not invalidate on non-transparent - // graphics due to performance reasons. - for(auto const & pAnimBmp : maList) - { - if( Disposal::Back == pAnimBmp->eDisposal - && tools::Rectangle( pAnimBmp->aPosPix, pAnimBmp->aSizePix ) != aRect - ) - { - bRet = true; - break; - } - } - - if( !bRet ) - bRet = maBitmapEx.IsTransparent(); - - return bRet; -} - -sal_uLong Animation::GetSizeBytes() const -{ - sal_uLong nSizeBytes = GetBitmapEx().GetSizeBytes(); - - for(auto const & pAnimBmp : maList) - { - nSizeBytes += pAnimBmp->aBmpEx.GetSizeBytes(); - } - - return nSizeBytes; -} - -BitmapChecksum Animation::GetChecksum() const -{ - SVBT32 aBT32; - BitmapChecksumOctetArray aBCOA; - BitmapChecksum nCrc = GetBitmapEx().GetChecksum(); - - UInt32ToSVBT32( maList.size(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( maGlobalSize.Width(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - Int32ToSVBT32( maGlobalSize.Height(), aBT32 ); - nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - - for(auto const & i : maList) - { - BCToBCOA( i->GetChecksum(), aBCOA ); - nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE ); - } - - return nCrc; -} - -bool Animation::Start( OutputDevice* pOut, const Point& rDestPt, const Size& rDestSz, long nExtraData, - OutputDevice* pFirstFrameOutDev ) -{ - bool bRet = false; - - if( !maList.empty() ) - { - if( ( pOut->GetOutDevType() == OUTDEV_WINDOW ) - && !mbLoopTerminated - && ( ANIMATION_TIMEOUT_ON_CLICK != maList[ mnPos ]->nWait ) - ) - { - ImplAnimView* pView; - ImplAnimView* pMatch = nullptr; - - for( size_t i = 0; i < maViewList.size(); ++i ) - { - pView = maViewList[ i ].get(); - if( pView->matches( pOut, nExtraData ) ) - { - if( pView->getOutPos() == rDestPt && - pView->getOutSizePix() == pOut->LogicToPixel( rDestSz ) ) - { - pView->repaint(); - pMatch = pView; - } - else - { - maViewList.erase( maViewList.begin() + i ); - pView = nullptr; - } - - break; - } - } - - if( maViewList.empty() ) - { - maTimer.Stop(); - mbIsInAnimation = false; - mnPos = 0; - } - - if( !pMatch ) - maViewList.emplace_back( new ImplAnimView( this, pOut, rDestPt, rDestSz, nExtraData, pFirstFrameOutDev ) ); - - if( !mbIsInAnimation ) - { - ImplRestartTimer( maList[ mnPos ]->nWait ); - mbIsInAnimation = true; - } - } - else - Draw( pOut, rDestPt, rDestSz ); - - bRet = true; - } - - return bRet; -} - -void Animation::Stop( OutputDevice* pOut, long nExtraData ) -{ - for( size_t i = 0; i < maViewList.size(); ) - { - ImplAnimView* pView = maViewList[ i ].get(); - if( pView->matches( pOut, nExtraData ) ) - { - maViewList.erase( maViewList.begin() + i ); - } - else - i++; - } - - if( maViewList.empty() ) - { - maTimer.Stop(); - mbIsInAnimation = false; - } -} - -void Animation::Draw( OutputDevice* pOut, const Point& rDestPt ) const -{ - Draw( pOut, rDestPt, pOut->PixelToLogic( maGlobalSize ) ); -} - -void Animation::Draw( OutputDevice* pOut, const Point& rDestPt, const Size& rDestSz ) const -{ - const size_t nCount = maList.size(); - - if( nCount ) - { - AnimationBitmap* pObj = maList[ std::min( mnPos, nCount - 1 ) ].get(); - - if( pOut->GetConnectMetaFile() - || ( pOut->GetOutDevType() == OUTDEV_PRINTER ) - ) - maList[ 0 ]->aBmpEx.Draw( pOut, rDestPt, rDestSz ); - else if( ANIMATION_TIMEOUT_ON_CLICK == pObj->nWait ) - pObj->aBmpEx.Draw( pOut, rDestPt, rDestSz ); - else - { - const size_t nOldPos = mnPos; - const_cast(this)->mnPos = mbLoopTerminated ? ( nCount - 1 ) : mnPos; - delete new ImplAnimView( const_cast(this), pOut, rDestPt, rDestSz, 0 ); - const_cast(this)->mnPos = nOldPos; - } - } -} - -void Animation::ImplRestartTimer( sal_uLong nTimeout ) -{ - maTimer.SetTimeout( std::max( nTimeout, static_cast(MIN_TIMEOUT) ) * 10 ); - maTimer.Start(); -} - -IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer *, void) -{ - const size_t nAnimCount = maList.size(); - - if( nAnimCount ) - { - ImplAnimView* pView; - bool bGlobalPause = true; - - if( maNotifyLink.IsSet() ) - { - std::vector< std::unique_ptr > aAInfoList; - // create AInfo-List - for(auto const & i : maViewList) - aAInfoList.emplace_back( i->createAInfo() ); - - maNotifyLink.Call( this ); - - // set view state from AInfo structure - for(auto& pAInfo : aAInfoList) - { - if( !pAInfo->pViewData ) - { - pView = new ImplAnimView( this, pAInfo->pOutDev, - pAInfo->aStartOrg, pAInfo->aStartSize, pAInfo->nExtraData ); - - maViewList.push_back( std::unique_ptr(pView) ); - } - else - pView = static_cast(pAInfo->pViewData); - - pView->pause( pAInfo->bPause ); - pView->setMarked( true ); - } - - // delete all unmarked views and reset marked state - for( size_t i = 0; i < maViewList.size(); ) - { - pView = maViewList[ i ].get(); - if( !pView->isMarked() ) - { - maViewList.erase( maViewList.begin() + i ); - } - else - { - if( !pView->isPause() ) - bGlobalPause = false; - - pView->setMarked( false ); - i++; - } - } - } - else - bGlobalPause = false; - - if( maViewList.empty() ) - Stop(); - else if( bGlobalPause ) - ImplRestartTimer( 10 ); - else - { - AnimationBitmap* pStepBmp = (++mnPos < maList.size()) ? maList[ mnPos ].get() : nullptr; - - if( !pStepBmp ) - { - if( mnLoops == 1 ) - { - Stop(); - mbLoopTerminated = true; - mnPos = nAnimCount - 1; - maBitmapEx = maList[ mnPos ]->aBmpEx; - return; - } - else - { - if( mnLoops ) - mnLoops--; - - mnPos = 0; - pStepBmp = maList[ mnPos ].get(); - } - } - - // Paint all views; after painting check, if view is - // marked; in this case remove view, because area of output - // lies out of display area of window; mark state is - // set from view itself - for( size_t i = 0; i < maViewList.size(); ) - { - pView = maViewList[ i ].get(); - pView->draw( mnPos ); - - if( pView->isMarked() ) - { - maViewList.erase( maViewList.begin() + i ); - } - else - i++; - } - - // stop or restart timer - if( maViewList.empty() ) - Stop(); - else - ImplRestartTimer( pStepBmp->nWait ); - } - } - else - Stop(); -} - -bool Animation::Insert( const AnimationBitmap& rStepBmp ) -{ - bool bRet = false; - - if( !IsInAnimation() ) - { - tools::Rectangle aGlobalRect( Point(), maGlobalSize ); - - maGlobalSize = aGlobalRect.Union( tools::Rectangle( rStepBmp.aPosPix, rStepBmp.aSizePix ) ).GetSize(); - maList.emplace_back( new AnimationBitmap( rStepBmp ) ); - - // As a start, we make the first BitmapEx the replacement BitmapEx - if( maList.size() == 1 ) - maBitmapEx = rStepBmp.aBmpEx; - - bRet = true; - } - - return bRet; -} - -const AnimationBitmap& Animation::Get( sal_uInt16 nAnimation ) const -{ - SAL_WARN_IF( ( nAnimation >= maList.size() ), "vcl", "No object at this position" ); - return *maList[ nAnimation ]; -} - -void Animation::Replace( const AnimationBitmap& rNewAnimationBitmap, sal_uInt16 nAnimation ) -{ - SAL_WARN_IF( ( nAnimation >= maList.size() ), "vcl", "No object at this position" ); - - maList[ nAnimation ].reset( new AnimationBitmap( rNewAnimationBitmap ) ); - - // If we insert at first position we also need to - // update the replacement BitmapEx - if ( ( !nAnimation - && ( !mbLoopTerminated - || ( maList.size() == 1 ) - ) - ) - || - ( ( nAnimation == maList.size() - 1 ) - && mbLoopTerminated - ) - ) - { - maBitmapEx = rNewAnimationBitmap.aBmpEx; - } -} - -void Animation::SetLoopCount(const sal_uInt32 nLoopCount) -{ - mnLoopCount = nLoopCount; - ResetLoopCount(); -} - -void Animation::ResetLoopCount() -{ - mnLoops = mnLoopCount; - mbLoopTerminated = false; -} - -void Animation::Convert( BmpConversion eConversion ) -{ - SAL_WARN_IF( IsInAnimation(), "vcl", "Animation modified while it is animated" ); - - bool bRet; - - if( !IsInAnimation() && !maList.empty() ) - { - bRet = true; - - for( size_t i = 0, n = maList.size(); ( i < n ) && bRet; ++i ) - bRet = maList[ i ]->aBmpEx.Convert( eConversion ); - - maBitmapEx.Convert( eConversion ); - } -} - -bool Animation::ReduceColors( sal_uInt16 nNewColorCount ) -{ - SAL_WARN_IF( IsInAnimation(), "vcl", "Animation modified while it is animated" ); - - bool bRet; - - if( !IsInAnimation() && !maList.empty() ) - { - bRet = true; - - for (size_t i = 0, n = maList.size(); (i < n) && bRet; ++i) - { - bRet = BitmapFilter::Filter(maList[i]->aBmpEx, BitmapColorQuantizationFilter(nNewColorCount)); - } - - BitmapFilter::Filter(maBitmapEx, BitmapColorQuantizationFilter(nNewColorCount)); - } - else - { - bRet = false; - } - - return bRet; -} - -bool Animation::Invert() -{ - SAL_WARN_IF( IsInAnimation(), "vcl", "Animation modified while it is animated" ); - - bool bRet; - - if( !IsInAnimation() && !maList.empty() ) - { - bRet = true; - - for( size_t i = 0, n = maList.size(); ( i < n ) && bRet; ++i ) - bRet = maList[ i ]->aBmpEx.Invert(); - - maBitmapEx.Invert(); - } - else - bRet = false; - - return bRet; -} - -void Animation::Mirror( BmpMirrorFlags nMirrorFlags ) -{ - SAL_WARN_IF( IsInAnimation(), "vcl", "Animation modified while it is animated" ); - - bool bRet; - - if( !IsInAnimation() && !maList.empty() ) - { - bRet = true; - - if( nMirrorFlags != BmpMirrorFlags::NONE ) - { - for( size_t i = 0, n = maList.size(); ( i < n ) && bRet; ++i ) - { - AnimationBitmap* pStepBmp = maList[ i ].get(); - bRet = pStepBmp->aBmpEx.Mirror( nMirrorFlags ); - if( bRet ) - { - if( nMirrorFlags & BmpMirrorFlags::Horizontal ) - pStepBmp->aPosPix.setX( maGlobalSize.Width() - pStepBmp->aPosPix.X() - pStepBmp->aSizePix.Width() ); - - if( nMirrorFlags & BmpMirrorFlags::Vertical ) - pStepBmp->aPosPix.setY( maGlobalSize.Height() - pStepBmp->aPosPix.Y() - pStepBmp->aSizePix.Height() ); - } - } - - maBitmapEx.Mirror( nMirrorFlags ); - } - } -} - -void Animation::Adjust( short nLuminancePercent, short nContrastPercent, - short nChannelRPercent, short nChannelGPercent, short nChannelBPercent, - double fGamma, bool bInvert ) -{ - SAL_WARN_IF( IsInAnimation(), "vcl", "Animation modified while it is animated" ); - - bool bRet; - - if( !IsInAnimation() && !maList.empty() ) - { - bRet = true; - - for( size_t i = 0, n = maList.size(); ( i < n ) && bRet; ++i ) - { - bRet = maList[ i ]->aBmpEx.Adjust( nLuminancePercent, - nContrastPercent, - nChannelRPercent, - nChannelGPercent, - nChannelBPercent, - fGamma, bInvert - ); - } - - maBitmapEx.Adjust( nLuminancePercent, nContrastPercent, - nChannelRPercent, nChannelGPercent, nChannelBPercent, - fGamma, bInvert ); - } -} - -SvStream& WriteAnimation( SvStream& rOStm, const Animation& rAnimation ) -{ - const sal_uInt16 nCount = rAnimation.Count(); - - if( nCount ) - { - const sal_uInt32 nDummy32 = 0; - - // If no BitmapEx was set we write the first Bitmap of - // the Animation - if( !rAnimation.GetBitmapEx().GetBitmap() ) - WriteDIBBitmapEx(rAnimation.Get( 0 ).aBmpEx, rOStm); - else - WriteDIBBitmapEx(rAnimation.GetBitmapEx(), rOStm); - - // Write identifier ( SDANIMA1 ) - rOStm.WriteUInt32( 0x5344414e ).WriteUInt32( 0x494d4931 ); - - for( sal_uInt16 i = 0; i < nCount; i++ ) - { - const AnimationBitmap& rAnimBmp = rAnimation.Get( i ); - const sal_uInt16 nRest = nCount - i - 1; - - // Write AnimationBitmap - WriteDIBBitmapEx(rAnimBmp.aBmpEx, rOStm); - WritePair( rOStm, rAnimBmp.aPosPix ); - WritePair( rOStm, rAnimBmp.aSizePix ); - WritePair( rOStm, rAnimation.maGlobalSize ); - rOStm.WriteUInt16( ( ANIMATION_TIMEOUT_ON_CLICK == rAnimBmp.nWait ) ? 65535 : rAnimBmp.nWait ); - rOStm.WriteUInt16( static_cast(rAnimBmp.eDisposal) ); - rOStm.WriteBool( rAnimBmp.bUserInput ); - rOStm.WriteUInt32( rAnimation.mnLoopCount ); - rOStm.WriteUInt32( nDummy32 ); // Unused - rOStm.WriteUInt32( nDummy32 ); // Unused - rOStm.WriteUInt32( nDummy32 ); // Unused - write_uInt16_lenPrefixed_uInt8s_FromOString(rOStm, OString()); // dummy - rOStm.WriteUInt16( nRest ); // Count of remaining structures - } - } - - return rOStm; -} - -SvStream& ReadAnimation( SvStream& rIStm, Animation& rAnimation ) -{ - sal_uLong nStmPos; - sal_uInt32 nAnimMagic1, nAnimMagic2; - SvStreamEndian nOldFormat = rIStm.GetEndian(); - bool bReadAnimations = false; - - rIStm.SetEndian( SvStreamEndian::LITTLE ); - nStmPos = rIStm.Tell(); - rIStm.ReadUInt32( nAnimMagic1 ).ReadUInt32( nAnimMagic2 ); - - rAnimation.Clear(); - - // If the BitmapEx at the beginning have already been read (by Graphic) - // we can start reading the AnimationBitmaps right away - if( ( nAnimMagic1 == 0x5344414e ) && ( nAnimMagic2 == 0x494d4931 ) && !rIStm.GetError() ) - bReadAnimations = true; - // Else, we try reading the Bitmap(-Ex) - else - { - rIStm.Seek( nStmPos ); - ReadDIBBitmapEx(rAnimation.maBitmapEx, rIStm); - nStmPos = rIStm.Tell(); - rIStm.ReadUInt32( nAnimMagic1 ).ReadUInt32( nAnimMagic2 ); - - if( ( nAnimMagic1 == 0x5344414e ) && ( nAnimMagic2 == 0x494d4931 ) && !rIStm.GetError() ) - bReadAnimations = true; - else - rIStm.Seek( nStmPos ); - } - - // Read AnimationBitmaps - if( bReadAnimations ) - { - AnimationBitmap aAnimBmp; - sal_uInt32 nTmp32; - sal_uInt16 nTmp16; - bool cTmp; - - do - { - ReadDIBBitmapEx(aAnimBmp.aBmpEx, rIStm); - ReadPair( rIStm, aAnimBmp.aPosPix ); - ReadPair( rIStm, aAnimBmp.aSizePix ); - ReadPair( rIStm, rAnimation.maGlobalSize ); - rIStm.ReadUInt16( nTmp16 ); aAnimBmp.nWait = ( ( 65535 == nTmp16 ) ? ANIMATION_TIMEOUT_ON_CLICK : nTmp16 ); - rIStm.ReadUInt16( nTmp16 ); aAnimBmp.eDisposal = static_cast(nTmp16); - rIStm.ReadCharAsBool( cTmp ); aAnimBmp.bUserInput = cTmp; - rIStm.ReadUInt32( rAnimation.mnLoopCount ); - rIStm.ReadUInt32( nTmp32 ); // Unused - rIStm.ReadUInt32( nTmp32 ); // Unused - rIStm.ReadUInt32( nTmp32 ); // Unused - read_uInt16_lenPrefixed_uInt8s_ToOString(rIStm); // Unused - rIStm.ReadUInt16( nTmp16 ); // The rest to read - - rAnimation.Insert( aAnimBmp ); - } - while( nTmp16 && !rIStm.GetError() ); - - rAnimation.ResetLoopCount(); - } - - rIStm.SetEndian( nOldFormat ); - - return rIStm; -} - -AInfo::AInfo() : pOutDev( nullptr ), - pViewData( nullptr ), - nExtraData( 0 ), - bPause( false ) {} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/graphic/GraphicObject2.cxx b/vcl/source/graphic/GraphicObject2.cxx index 7349e8b25c63..bfb31740def7 100644 --- a/vcl/source/graphic/GraphicObject2.cxx +++ b/vcl/source/graphic/GraphicObject2.cxx @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include -- cgit