101 QString idBase = base.isEmpty() ?
"defitem" : base;
102 int counter =
d->uniqueNames.value(idBase);
105 res = idBase + QString::number(counter);
107 }
while (
d->uniqueNames.contains(res));
109 d->uniqueNames.insert(idBase, counter);
110 d->uniqueNames.insert(res, 1);
161 QFile *file = qobject_cast<QFile*>(
d->mainDevice);
165 QFileInfo fi(file->fileName());
166 QString path = fi.absolutePath();
167 QString dstBaseFilename = fi.completeBaseName();
170 QString fname = dstBaseFilename +
'_' +
createUID(
"file");
176 while (QFile(path + fname + counter + extension).exists()) {
177 counter = QString(
"_%1").arg(++i);
180 return fname + counter + extension;
Context for saving svg files.
QString createUID(const QString &base)
Create a unique id from the specified base text.
virtual ~SvgSavingContext()
Virtual destructor.
QTransform userSpaceTransform() const
Returns the transformation used to transform into user space.
QHash< const KoShape *, QString > shapeIds
QString saveImage(const QImage &image)
Saves given image and returns the href used.
QScopedPointer< KoXmlWriter > shapeWriter
QString getID(const KoShape *obj)
Returns the unique id for the given shape.
bool isSavingInlineImages() const
Returns if image should be saved inline.
QTransform userSpaceMatrix
QHash< QString, int > uniqueNames
void setStrippedTextMode(bool value)
QString createFileName(const QString &extension)
Create a filename suitable for saving external data.
SvgSavingContext(QIODevice &outputDevice, bool saveInlineImages=true)
Creates a new svg saving context on the specified output device.
Private(QIODevice *_mainDevice, QIODevice *_styleDevice)
QScopedPointer< KoXmlWriter > styleWriter