summaryrefslogtreecommitdiff
path: root/svtools/source/graphic/grfcache.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'svtools/source/graphic/grfcache.cxx')
-rw-r--r--svtools/source/graphic/grfcache.cxx92
1 files changed, 61 insertions, 31 deletions
diff --git a/svtools/source/graphic/grfcache.cxx b/svtools/source/graphic/grfcache.cxx
index 03de750ebc86..03ccbc92cb6c 100644
--- a/svtools/source/graphic/grfcache.cxx
+++ b/svtools/source/graphic/grfcache.cxx
@@ -1,31 +1,21 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
+/*
+ * This file is part of the LibreOffice project.
*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 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/.
*
- * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * This file incorporates work covered by the following license notice:
*
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
+ * 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 <salhelper/timer.hxx>
#include <svtools/grfmgr.hxx>
@@ -35,7 +25,7 @@
#include <tools/poly.hxx>
#include <rtl/strbuf.hxx>
#include "grfcache.hxx"
-
+#include <rtl/crc.h>
#include <memory>
// -----------
@@ -94,7 +84,17 @@ GraphicID::GraphicID( const GraphicObject& rObj )
{
case( GRAPHIC_BITMAP ):
{
- if( rGraphic.IsAnimated() )
+ if(rGraphic.getSvgData().get())
+ {
+ const SvgDataPtr& rSvgDataPtr = rGraphic.getSvgData();
+ const basegfx::B2DRange& rRange = rSvgDataPtr->getRange();
+
+ mnID1 |= rSvgDataPtr->getSvgDataArrayLength();
+ mnID2 = basegfx::fround(rRange.getWidth());
+ mnID3 = basegfx::fround(rRange.getHeight());
+ mnID4 = rtl_crc32(0, rSvgDataPtr->getSvgDataArray().get(), rSvgDataPtr->getSvgDataArrayLength());
+ }
+ else if( rGraphic.IsAnimated() )
{
const Animation aAnimation( rGraphic.GetAnimation() );
@@ -172,7 +172,11 @@ private:
Animation* mpAnimation;
bool mbSwappedAll;
+ // SvgData support
+ SvgDataPtr maSvgData;
+
bool ImplInit( const GraphicObject& rObj );
+ bool ImplMatches( const GraphicObject& rObj ) const { return( GraphicID( rObj ) == maID ); }
void ImplFillSubstitute( Graphic& rSubstitute );
public:
@@ -200,8 +204,9 @@ GraphicCacheEntry::GraphicCacheEntry( const GraphicObject& rObj ) :
mpBmpEx ( NULL ),
mpMtf ( NULL ),
mpAnimation ( NULL ),
- mbSwappedAll ( !ImplInit( rObj ) )
+ mbSwappedAll ( true )
{
+ mbSwappedAll = !ImplInit( rObj );
maGraphicObjectList.push_back( (GraphicObject*)&rObj );
}
@@ -242,10 +247,18 @@ bool GraphicCacheEntry::ImplInit( const GraphicObject& rObj )
{
case( GRAPHIC_BITMAP ):
{
- if( rGraphic.IsAnimated() )
+ if(rGraphic.getSvgData().get())
+ {
+ maSvgData = rGraphic.getSvgData();
+ }
+ else if( rGraphic.IsAnimated() )
+ {
mpAnimation = new Animation( rGraphic.GetAnimation() );
+ }
else
+ {
mpBmpEx = new BitmapEx( rGraphic.GetBitmapEx() );
+ }
}
break;
@@ -287,14 +300,26 @@ void GraphicCacheEntry::ImplFillSubstitute( Graphic& rSubstitute )
if( rSubstitute.IsLink() && ( GFX_LINK_TYPE_NONE == maGfxLink.GetType() ) )
maGfxLink = rSubstitute.GetLink();
- if( mpBmpEx )
+ if(maSvgData.get())
+ {
+ rSubstitute = maSvgData;
+ }
+ else if( mpBmpEx )
+ {
rSubstitute = *mpBmpEx;
+ }
else if( mpAnimation )
+ {
rSubstitute = *mpAnimation;
+ }
else if( mpMtf )
+ {
rSubstitute = *mpMtf;
+ }
else
+ {
rSubstitute.Clear();
+ }
if( eOldType != GRAPHIC_NONE )
{
@@ -305,10 +330,14 @@ void GraphicCacheEntry::ImplFillSubstitute( Graphic& rSubstitute )
}
if( GFX_LINK_TYPE_NONE != maGfxLink.GetType() )
+ {
rSubstitute.SetLink( maGfxLink );
+ }
if( bDefaultType )
+ {
rSubstitute.SetDefaultType();
+ }
}
// -----------------------------------------------------------------------------
@@ -377,6 +406,9 @@ void GraphicCacheEntry::GraphicObjectWasSwappedOut( const GraphicObject& /*rObj*
delete mpBmpEx, mpBmpEx = NULL;
mpMtf = NULL; // No need to delete it as it has already been dereferenced
delete mpAnimation, mpAnimation = NULL;
+
+ // #119176# also reset SvgData
+ maSvgData.reset();
}
}
@@ -748,8 +780,6 @@ bool GraphicDisplayCacheEntry::IsCacheableAsBitmap( const GDIMetaFile& rMtf,
// FALLTHROUGH intended
case META_GRADIENTEX_ACTION:
// FALLTHROUGH intended
- case META_RENDERGRAPHIC_ACTION:
- // FALLTHROUGH intended
// OutDev state changes that _do_ affect bitmap
// output