Commit cbbb204c authored by Jan Hambrecht's avatar Jan Hambrecht

use KoImageData in KoPattern Background to manage the pattern data

added preliminary support for image background rendering styles


svn path=/trunk/koffice/; revision=821196
parent ab28658b
This diff is collapsed.
......@@ -24,14 +24,18 @@
#include "flake_export.h"
#include <QtGui/QMatrix>
class KoImageCollection;
/// A pattern shape background
class FLAKE_EXPORT KoPatternBackground : public KoShapeBackground
{
public:
KoPatternBackground();
/// Pattern rendering style
enum PatternRepeat { Original, Tiled, Stretched };
/// Pattern reference point
enum ReferencePoint { None, TopLeft, Top, TopRight, Left, Center, Right, BottomLeft, Bottom, BottomRight };
/// Creates new pattern background with the given pattern image
KoPatternBackground( const QImage &pattern );
KoPatternBackground( KoImageCollection *collection );
virtual ~KoPatternBackground();
......@@ -46,6 +50,12 @@ public:
/// Returns the pattern
QImage pattern();
/// Sets the pattern repeat
void setPatternRepeat( PatternRepeat repeat );
/// Returns the pattern repeat
PatternRepeat patternRepeat() const;
/// Assignment operator
KoPatternBackground& operator = ( const KoPatternBackground &rhs );
......
......@@ -867,7 +867,7 @@ KoShapeBackground * KoShape::loadOdfFill( const KoXmlElement & element, KoShapeL
else if( fill == "gradient" )
bg = new KoGradientBackground( new QLinearGradient() );
else if( fill == "bitmap" )
bg = new KoPatternBackground();
bg = new KoPatternBackground( context.imageCollection() );
if( ! bg )
return 0;
......
......@@ -22,6 +22,9 @@
#include "KoShape.h"
#include "KoShapeContainer.h"
#include "KoSharedLoadingData.h"
#include "KoShapeControllerBase.h"
#include "KoDataCenter.h"
#include "KoImageCollection.h"
#include <kdebug.h>
......@@ -36,7 +39,6 @@ class KoShapeLoadingContext::Private {
public:
Private( KoOdfLoadingContext &c, KoShapeControllerBase * sc )
: context( c )
, imageCollection( 0 )
, zIndex( 0 )
, shapeController( sc )
{}
......@@ -50,7 +52,6 @@ public:
KoOdfLoadingContext &context;
QMap<QString, KoShapeLayer*> layers;
QMap<QString, KoShape*> drawIds;
KoImageCollection * imageCollection;
QMap<QString, KoSharedLoadingData*> sharedData;
QMap<KoShape*, int> zIndices;
int zIndex;
......@@ -92,14 +93,13 @@ KoShape * KoShapeLoadingContext::shapeById( const QString & id )
return d->drawIds.value( id, 0 );
}
void KoShapeLoadingContext::setImageCollection( KoImageCollection * imageCollection )
{
d->imageCollection = imageCollection;
}
KoImageCollection * KoShapeLoadingContext::imageCollection()
{
return d->imageCollection;
if( ! d->shapeController )
return 0;
QMap<QString, KoDataCenter *> dataCenterMap = d->shapeController->dataCenterMap();
return dynamic_cast<KoImageCollection*>( dataCenterMap.value( "ImageCollection", 0 ) );
}
int KoShapeLoadingContext::zIndex()
......
......@@ -93,9 +93,6 @@ public:
/// return the shape formerly registered using addShapeId()
KoShape * shapeById( const QString & id );
/// Sets the image collection used for loading images
void setImageCollection( KoImageCollection * imageCollection );
/// Returns the image collection for loading images
KoImageCollection * imageCollection();
......
......@@ -58,6 +58,10 @@ bool PictureShapeFactory::supports(const KoXmlElement & e) const
void PictureShapeFactory::populateDataCenterMap(QMap<QString, KoDataCenter *> & dataCenterMap)
{
KoImageCollection *imgCol = new KoImageCollection();
dataCenterMap["ImageCollection"] = imgCol;
// only add image collection if none exist already
if( ! dataCenterMap.contains( "ImageCollection" ) )
{
KoImageCollection *imgCol = new KoImageCollection();
dataCenterMap["ImageCollection"] = imgCol;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment