Commit c0ba3d92 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Save and load xml:id as well as text:id and draw:id where necessary

ODF 1.2 migrates from draw:id and text:id to xml:id in most cases. This
patch introduces a new class, KoElementReference, that makes handling
id's mostly transparent.

It also changes KoShapeSavingContext to manage references and id's in
a transparent manner when saving. Most filters, even those that are
currently useless, have also been updated.

BUG:288644
REVIEW: 104074
parent 605fc2e9
......@@ -21,7 +21,6 @@
#include "kis_shape_layer.h"
#include <QPainter>
#include <QPainterPath>
#include <QRect>
......@@ -39,6 +38,7 @@
#include <kicon.h>
#include <kdebug.h>
#include <KoElementReference.h>
#include <KoColorSpace.h>
#include <KoCompositeOp.h>
#include <KoDataCenterBase.h>
......@@ -328,7 +328,10 @@ bool KisShapeLayer::saveLayer(KoStore * store) const
shapeContext.xmlWriter().startElement("draw:page");
shapeContext.xmlWriter().addAttribute("draw:name", "");
shapeContext.xmlWriter().addAttribute("draw:id", "page1");
KoElementReference elementRef("page", 1);
elementRef.saveOdf(&shapeContext.xmlWriter(), KoElementReference::DrawId);
shapeContext.xmlWriter().addAttribute("draw:master-page-name", "Default");
saveOdf(shapeContext);
......
......@@ -49,6 +49,7 @@
#include <KoShapeSavingContext.h>
#include <KoStoreDevice.h>
#include <KoShapeTransformCommand.h>
#include <KoElementReference.h>
#include "kis_painter.h"
#include "kis_paint_device.h"
......@@ -159,7 +160,10 @@ bool KisShapeSelection::saveSelection(KoStore * store) const
shapeContext.xmlWriter().startElement("draw:page");
shapeContext.xmlWriter().addAttribute("draw:name", "");
shapeContext.xmlWriter().addAttribute("draw:id", "page1");
KoElementReference elementRef;
elementRef.saveOdf(&shapeContext.xmlWriter(), KoElementReference::DrawId);
shapeContext.xmlWriter().addAttribute("draw:master-page-name", "Default");
saveOdf(shapeContext);
......
......@@ -345,7 +345,7 @@ void KoConnectionShape::saveOdf(KoShapeSavingContext & context) const
}
if (d->shape1) {
context.xmlWriter().addAttribute("draw:start-shape", context.drawId(d->shape1));
context.xmlWriter().addAttribute("draw:start-shape", context.xmlid(d->shape1, "shape", KoElementReference::Counter).toString());
context.xmlWriter().addAttribute("draw:start-glue-point", d->connectionPointId1);
} else {
QPointF p(shapeToDocument(d->handles[StartHandle]) * context.shapeOffset(this));
......@@ -353,7 +353,7 @@ void KoConnectionShape::saveOdf(KoShapeSavingContext & context) const
context.xmlWriter().addAttributePt("svg:y1", p.y());
}
if (d->shape2) {
context.xmlWriter().addAttribute("draw:end-shape", context.drawId(d->shape2));
context.xmlWriter().addAttribute("draw:end-shape", context.xmlid(d->shape2, "shape", KoElementReference::Counter).toString());
context.xmlWriter().addAttribute("draw:end-glue-point", d->connectionPointId2);
} else {
QPointF p(shapeToDocument(d->handles[EndHandle]) * context.shapeOffset(this));
......
......@@ -218,8 +218,6 @@ void KoImageCollection::update(qint64 oldKey, qint64 newKey)
d->images.remove(oldKey);
d->images.insert(newKey, imageData);
}
Q_ASSERT(d->images.contains(newKey));
Q_ASSERT(!d->images.contains(oldKey));
}
void KoImageCollection::removeOnKey(qint64 imageDataKey)
......
......@@ -49,6 +49,7 @@
#include "KoOdfWorkaround.h"
#include "KoFilterEffectStack.h"
#include <KoSnapData.h>
#include <KoElementReference.h>
#include <KoXmlReader.h>
#include <KoXmlWriter.h>
......@@ -1381,11 +1382,10 @@ bool KoShape::loadOdfAttributes(const KoXmlElement &element, KoShapeLoadingConte
}
if (attributes & OdfId) {
if (element.hasAttributeNS(KoXmlNS::draw, "id")) {
QString id = element.attributeNS(KoXmlNS::draw, "id");
if (!id.isNull()) {
context.addShapeId(this, id);
}
KoElementReference ref;
ref.loadOdf(element);
if (ref.isValid()) {
context.addShapeId(this, ref.toString());
}
}
......@@ -1571,6 +1571,9 @@ void KoShape::loadOdfGluePoints(const KoXmlElement &element, KoShapeLoadingConte
if (child.localName() != "glue-point")
continue;
// NOTE: this uses draw:id, but apparently while ODF 1.2 has deprecated
// all use of draw:id for xml:id, it didn't specify that here, so it
// doesn't support xml:id (and so, maybe, shouldn't use KoElementReference.
const QString id = child.attributeNS(KoXmlNS::draw, "id", QString());
const int index = id.toInt();
if(id.isEmpty() || index < 4 || d->connectors.contains(index)) {
......@@ -1748,8 +1751,8 @@ void KoShape::saveOdfAttributes(KoShapeSavingContext &context, int attributes) c
if (attributes & OdfId) {
if (context.isSet(KoShapeSavingContext::DrawId)) {
context.xmlWriter().addAttribute("draw:id", context.drawId(this));
context.xmlWriter().addAttribute("xml:id", context.drawId(this));
KoElementReference ref = context.xmlid(this, "shape", KoElementReference::Counter);
ref.saveOdf(&context.xmlWriter(), KoElementReference::DrawId);
}
}
......@@ -1855,7 +1858,6 @@ void KoShape::saveOdfCommonChildElements(KoShapeSavingContext &context) const
continue;
context.xmlWriter().startElement("draw:glue-point");
context.xmlWriter().addAttribute("draw:id", QString("%1").arg(cp.key()));
context.xmlWriter().addAttribute("xml:id", QString("%1").arg(cp.key()));
if (cp.value().alignment == KoConnectionPoint::AlignNone) {
// convert to percent from center
const qreal x = cp.value().position.x() * 100.0 - 50.0;
......
......@@ -43,7 +43,8 @@ public:
Private(KoOdfLoadingContext &c, KoDocumentResourceManager *resourceManager)
: context(c),
zIndex(0),
documentResources(resourceManager)
documentResources(resourceManager),
documentRdf(0)
{
}
~Private() {
......@@ -60,6 +61,7 @@ public:
QMap<QString, KoLoadingShapeUpdater*> updaterById;
QMap<KoShape *, KoLoadingShapeUpdater*> updaterByShape;
KoDocumentResourceManager *documentResources;
QObject *documentRdf;
};
KoShapeLoadingContext::KoShapeLoadingContext(KoOdfLoadingContext & context, KoDocumentResourceManager *documentResources)
......@@ -191,3 +193,14 @@ KoDocumentResourceManager *KoShapeLoadingContext::documentResourceManager() cons
{
return d->documentResources;
}
QObject *KoShapeLoadingContext::documentRdf() const
{
return d->documentRdf;
}
void KoShapeLoadingContext::setDocumentRdf(QObject *documentRdf)
{
d->documentRdf = documentRdf;
}
......@@ -176,6 +176,18 @@ public:
KoDocumentResourceManager *documentResourceManager() const;
/**
* @brief get the rdf document
* @return the rdf document, or 0 if there is none set/
*/
QObject *documentRdf() const;
/**
* @brief setDocumentRdf sets the rdf document for the loading context
* @param documentRdf the rdf document -- it needs to have been loaded already
*/
void setDocumentRdf(QObject *documentRdf);
private:
// to allow only the KoShapeRegistry access to the KoShapeBasedDocumentBase
class Private;
......
......@@ -31,10 +31,12 @@
#include <KoStore.h>
#include <KoStoreDevice.h>
#include <KoSharedSavingData.h>
#include <KoElementReference.h>
#include <kmimetype.h>
#include <kdebug.h>
#include <QMap>
#include <QUuid>
class KoShapeSavingContextPrivate {
public:
......@@ -43,29 +45,31 @@ public:
KoXmlWriter *xmlWriter;
KoShapeSavingContext::ShapeSavingOptions savingOptions;
QMap<const KoShape *, QString> drawIds;
QMap<const QTextBlockUserData*, QString> subIds;
QList<const KoShapeLayer*> layers;
QSet<KoDataCenterBase *> dataCenters;
int drawId;
int subId;
QMap<QString, KoSharedSavingData*> sharedData;
QMap<qint64, QString> imageNames;
int imageId;
QMap<QString, QImage> images;
QHash<const KoShape *, QTransform> shapeOffsets;
QMap<const KoMarker *, QString> markerRefs;
KoGenStyles& mainStyles;
KoEmbeddedDocumentSaver& embeddedSaver;
QMap<const void*, KoElementReference> references;
QMap<QString, int> referenceCounters;
QMap<QString, QList<const void*> > prefixedReferences;
};
KoShapeSavingContextPrivate::KoShapeSavingContextPrivate(KoXmlWriter &w,
KoGenStyles &s, KoEmbeddedDocumentSaver &e)
: xmlWriter(&w),
savingOptions(0),
drawId(0),
subId(0),
imageId(0),
mainStyles(s),
embeddedSaver(e)
......@@ -83,7 +87,7 @@ KoShapeSavingContext::KoShapeSavingContext(KoXmlWriter &xmlWriter, KoGenStyles &
KoEmbeddedDocumentSaver &embeddedSaver)
: d(new KoShapeSavingContextPrivate(xmlWriter, mainStyles, embeddedSaver))
{
// by default allow saving of draw:id
// by default allow saving of draw:id + xml:id
addOption(KoShapeSavingContext::DrawId);
}
......@@ -138,36 +142,64 @@ void KoShapeSavingContext::removeOption(ShapeSavingOption option)
d->savingOptions = d->savingOptions ^ option; // xor to remove it.
}
QString KoShapeSavingContext::drawId(const KoShape *shape, bool insert)
KoElementReference KoShapeSavingContext::xmlid(const void *referent, const QString& prefix, KoElementReference::GenerationOption counter)
{
QMap<const KoShape *, QString>::iterator it(d->drawIds.find(shape));
if (it == d->drawIds.end()) {
if (insert == true) {
it = d->drawIds.insert(shape, QString("shape%1").arg(++d->drawId));
} else {
return QString();
Q_ASSERT(counter == KoElementReference::UUID || (counter == KoElementReference::Counter && !prefix.isEmpty()));
if (d->references.contains(referent)) {
return d->references[referent];
}
KoElementReference ref;
if (counter == KoElementReference::Counter) {
int referenceCounter = d->referenceCounters[prefix];
referenceCounter++;
ref = KoElementReference(prefix, referenceCounter);
d->references.insert(referent, ref);
d->referenceCounters[prefix] = referenceCounter;
}
else {
if (!prefix.isEmpty()) {
ref = KoElementReference(prefix);
d->references.insert(referent, ref);
}
else {
d->references.insert(referent, ref);
}
}
return it.value();
if (!prefix.isNull()) {
d->prefixedReferences[prefix].append(referent);
}
return ref;
}
void KoShapeSavingContext::clearDrawIds()
KoElementReference KoShapeSavingContext::existingXmlid(const void *referent)
{
d->drawIds.clear();
d->drawId = 0;
if (d->references.contains(referent)) {
return d->references[referent];
}
else {
KoElementReference ref;
ref.invalidate();
return ref;
}
}
QString KoShapeSavingContext::subId(const QTextBlockUserData *subItem, bool insert)
void KoShapeSavingContext::clearXmlIds(const QString &prefix)
{
QMap<const QTextBlockUserData*, QString>::iterator it(d->subIds.find(subItem));
if (it == d->subIds.end()) {
if (insert == true) {
it = d->subIds.insert(subItem, QString("subitem%1").arg(++d->subId));
} else {
return QString();
if (d->prefixedReferences.contains(prefix)) {
foreach(const void* ptr, d->prefixedReferences[prefix]) {
d->references.remove(ptr);
}
d->prefixedReferences.remove(prefix);
}
if (d->referenceCounters.contains(prefix)) {
d->referenceCounters[prefix] = 0;
}
return it.value();
}
void KoShapeSavingContext::addLayerForSaving(const KoShapeLayer *layer)
......
......@@ -28,6 +28,7 @@
#include <QImage>
#include <QTransform>
#include <QTextBlockUserData>
#include <KoElementReference.h>
class KoShape;
class KoXmlWriter;
......@@ -56,7 +57,8 @@ public:
*/
PresentationShape = 1,
/**
* Save the draw:id used for referencing the shape.
* Save the draw:id used for referencing the shape. If draw:id is saved, xml:id is also
* saved.
* See OpenDocument 9.2.15 Common Drawing Shape Attributes / ID
*/
DrawId = 2,
......@@ -139,39 +141,32 @@ public:
*/
ShapeSavingOptions options() const;
/**
* @brief Get the draw id for a shape
*
* The draw:id is unique for all shapes.
*
* @param shape for which the draw id should be returned
* @param insert if true a new draw id will be generated if there is non yet
*
* @return the draw id for the shape or and empty string if it was not found
* @brief xmlid returns an element reference that can be related to the given referent. If there is a
* prefix given, this prefix will be used in addition to either the counter or the uuid.
* @param referent the object we are referring to
* @param prefix a prefix for the xml:id string
* @param counter if counter is true, shapesavingcontext will use a counter to create the xml:id
* @return a KoElementReference; if insert is false and referent doesn't exist yet in the list, the elementrefence will be invalid.
*/
KoElementReference xmlid(const void *referent, const QString& prefix = QString::null, KoElementReference::GenerationOption counter = KoElementReference::UUID);
/**
* @brief existingXmlid retrieve an existing xml id or invalid xml id if the referent object doesn't exist
*/
QString drawId(const KoShape *shape, bool insert = true);
KoElementReference existingXmlid(const void *referent);
/**
* @brief Clear out all given draw ids
* @param prefix: removes all xml:id's that have the given prefix.
*
* This is needed for checking if master pages are the same. In normal saving
* this should not be called.
*
* @see KoPAPastePage::process
*/
void clearDrawIds();
/**
* @brief Get the text id for a sub-item
*
* The text:id is unique for all sub-item.
*
* @param subitem for which the sub-item id should be returned
* @param insert if true a new sub-item id will be generated if there is non yet
*
* @return the sub-item id for the sub-item or and empty string if it was not found
*/
QString subId(const QTextBlockUserData *subItem, bool insert = true);
void clearXmlIds(const QString &prefix);
/**
* Adds a layer to save into a layer-set in styles.xml according to 9.1.2/9.1.3 odf spec
......@@ -256,7 +251,7 @@ public:
*/
KoSharedSavingData *sharedData(const QString &id) const;
/*
/**
* Add an offset that will be applied to the shape position when saved
*
* This is needed e.g. for shapes anchored to a text shape as the position is
......
......@@ -277,7 +277,6 @@ QList<KoPAPageBase *> KoPADocument::loadOdfMasterPages( const QHash<QString, KoX
int count = 0;
for ( ; it != masterStyles.constEnd(); ++it )
{
kDebug(30010) << "Master:" << it.key();
KoPAMasterPage * masterPage = newMasterPage();
masterPage->loadOdf( *( it.value() ), context );
masterPages.append( masterPage );
......@@ -356,7 +355,7 @@ bool KoPADocument::saveOdfPages( KoPASavingContext &paContext, QList<KoPAPageBas
// save master pages
foreach( KoPAPageBase *page, masterPages ) {
if ( paContext.isSetClearDrawIds() ) {
paContext.clearDrawIds();
paContext.clearXmlIds("shape");
}
page->saveOdf( paContext );
}
......
......@@ -51,7 +51,6 @@ KoPAPage::~KoPAPage()
void KoPAPage::saveOdf( KoShapeSavingContext & context ) const
{
KoPASavingContext &paContext = static_cast<KoPASavingContext&>( context );
paContext.xmlWriter().startElement( "draw:page" );
paContext.xmlWriter().addAttribute( "draw:name", paContext.pageName( this ) );
if (!name().isEmpty() && name() != paContext.pageName( this )) {
......
......@@ -45,12 +45,13 @@ bool KoPAPastePage::process( const KoXmlElement & body, KoOdfReadStore & odfStor
KoOdfLoadingContext loadingContext( odfStore.styles(), odfStore.store(), m_doc->componentData() );
KoPALoadingContext paContext(loadingContext, m_doc->resourceManager());
QList<KoPAPageBase *> masterPages( m_doc->loadOdfMasterPages( odfStore.styles().masterPages(), paContext ) );
QList<KoPAPageBase *> pages( m_doc->loadOdfPages( body, paContext ) );
QList<KoPAPageBase *> newMasterPages( m_doc->loadOdfMasterPages( odfStore.styles().masterPages(), paContext ) );
QList<KoPAPageBase *> newPages( m_doc->loadOdfPages( body, paContext ) );
// Check where to start inserting pages
KoPAPageBase * insertAfterPage = 0;
KoPAPageBase * insertAfterMasterPage = 0;
if ( dynamic_cast<KoPAMasterPage *>( m_activePage ) || ( m_activePage == 0 && pages.empty() ) ) {
if ( dynamic_cast<KoPAMasterPage *>( m_activePage ) || ( m_activePage == 0 && newPages.empty() ) ) {
insertAfterMasterPage = m_activePage;
insertAfterPage = m_doc->pages( false ).last();
}
......@@ -59,7 +60,7 @@ bool KoPAPastePage::process( const KoXmlElement & body, KoOdfReadStore & odfStor
insertAfterMasterPage = m_doc->pages( true ).last();
}
if ( ! pages.empty() ) {
if ( !newPages.empty() ) {
KoGenStyles mainStyles;
QBuffer buffer;
buffer.open( QIODevice::WriteOnly );
......@@ -87,10 +88,10 @@ bool KoPAPastePage::process( const KoXmlElement & body, KoOdfReadStore & odfStor
}
m_doc->saveOdfPages( savingContext, emptyList, masterPages );
m_doc->saveOdfPages( savingContext, emptyList, newMasterPages );
QMap<KoPAMasterPage*, KoPAMasterPage*> updateMasterPage;
foreach ( KoPAPageBase * page, masterPages )
QMap<KoPAMasterPage*, KoPAMasterPage*> masterPagesToUpdate;
foreach ( KoPAPageBase * page, newMasterPages )
{
KoPAMasterPage * masterPage = dynamic_cast<KoPAMasterPage*>( page );
Q_ASSERT( masterPage );
......@@ -98,49 +99,49 @@ bool KoPAPastePage::process( const KoXmlElement & body, KoOdfReadStore & odfStor
QString masterPageName( savingContext.masterPageName( masterPage ) );
QMap<QString, KoPAMasterPage*>::const_iterator existingMasterPage( masterPageNames.constFind( masterPageName ) );
if ( existingMasterPage != masterPageNames.constEnd() ) {
updateMasterPage.insert( masterPage, existingMasterPage.value() );
masterPagesToUpdate.insert( masterPage, existingMasterPage.value() );
}
}
}
// update pages which have a duplicate master page
foreach ( KoPAPageBase * page, pages )
foreach ( KoPAPageBase * page, newPages )
{
KoPAPage * p = dynamic_cast<KoPAPage*>( page );
Q_ASSERT( p );
if ( p ) {
KoPAMasterPage * masterPage( p->masterPage() );
QMap<KoPAMasterPage*, KoPAMasterPage*>::const_iterator pageIt( updateMasterPage.constFind( masterPage ) );
if ( pageIt != updateMasterPage.constEnd() ) {
QMap<KoPAMasterPage*, KoPAMasterPage*>::const_iterator pageIt( masterPagesToUpdate.constFind( masterPage ) );
if ( pageIt != masterPagesToUpdate.constEnd() ) {
p->setMasterPage( pageIt.value() );
}
}
}
// delete dumplicate master pages;
QMap<KoPAMasterPage*, KoPAMasterPage*>::const_iterator pageIt( updateMasterPage.constBegin() );
for ( ; pageIt != updateMasterPage.constEnd(); ++pageIt )
// delete duplicate master pages;
QMap<KoPAMasterPage*, KoPAMasterPage*>::const_iterator pageIt( masterPagesToUpdate.constBegin() );
for ( ; pageIt != masterPagesToUpdate.constEnd(); ++pageIt )
{
masterPages.removeAll( pageIt.key() );
newMasterPages.removeAll( pageIt.key() );
delete pageIt.key();
}
}
KUndo2Command * cmd = 0;
if ( m_doc->pageType() == KoPageApp::Slide ) {
cmd = new KUndo2Command( i18ncp( "(qtundo-format)", "Paste Slide", "Paste Slides", qMax( masterPages.size(), pages.size() ) ) );
cmd = new KUndo2Command( i18ncp( "(qtundo-format)", "Paste Slide", "Paste Slides", qMax( newMasterPages.size(), newPages.size() ) ) );
}
else {
cmd = new KUndo2Command( i18ncp( "(qtundo-format)", "Paste Page", "Paste Pages", qMax( masterPages.size(), pages.size() ) ) );
cmd = new KUndo2Command( i18ncp( "(qtundo-format)", "Paste Page", "Paste Pages", qMax( newMasterPages.size(), newPages.size() ) ) );
}
foreach( KoPAPageBase * masterPage, masterPages )
foreach( KoPAPageBase * masterPage, newMasterPages )
{
new KoPAPageInsertCommand( m_doc, masterPage, insertAfterMasterPage, cmd );
insertAfterMasterPage = masterPage;
}
foreach( KoPAPageBase * page, pages )
foreach( KoPAPageBase * page, newPages )
{
new KoPAPageInsertCommand( m_doc, page, insertAfterPage, cmd );
insertAfterPage = page;
......
......@@ -45,7 +45,6 @@ QMimeData * TestPACopyPastePage::copy( MockDocument * doc, QList<KoPAPageBase *>
KoPAOdfPageSaveHelper saveHelper( doc, pages );
KoDrag drag;
drag.setOdf( KoOdf::mimeType( doc->documentType() ), saveHelper );
return drag.mimeData();
}
......@@ -174,7 +173,7 @@ void TestPACopyPastePage::copyPasteSingleMasterPage()
QVERIFY( doc.pages( true )[3] == master2 );
}
void TestPACopyPastePage::copyPasteMuliplePages()
void TestPACopyPastePage::copyPasteMultiplePages()
{
MockDocument doc;
......@@ -257,7 +256,7 @@ void TestPACopyPastePage::copyPasteMuliplePages()
QVERIFY( page9->masterPage() == master1 );
}
void TestPACopyPastePage::copyPasteMulipleMasterPages()
void TestPACopyPastePage::copyPasteMultipleMasterPages()
{
MockDocument doc;
......
......@@ -36,11 +36,12 @@ private:
void addShape( KoPAPageBase * page );
QPointF m_pos;
private slots:
void copyPasteMultiplePages();
void copyPasteSinglePage();
void copyPasteSingleMasterPage();
void copyPasteMuliplePages();
void copyPasteMulipleMasterPages();
void copyPasteMultipleMasterPages();
void copyPasteMixedPages();
};
......
......@@ -76,3 +76,8 @@ bool KoDocumentRdfBase::completeSaving(KoStore */*store*/, KoXmlWriter */*manife
{
return false;
}
QStringList KoDocumentRdfBase::idrefList() const
{
return QStringList();
}
......@@ -65,6 +65,16 @@ public:
virtual void updateInlineRdfStatements(const QTextDocument *qdoc);
virtual void updateXmlIdReferences(const QMap<QString, QString> &m);
/**
* idrefList queries soprano after loading and creates a list of all rdfid's that
* where found in the manifest.rdf document. This list is used to make sure we do not
* create more inline rdf objects than necessary
* @return a list of xml-id's
*/
virtual QStringList idrefList() const;
virtual bool loadOasis(KoStore *store);
virtual bool saveOasis(KoStore *store, KoXmlWriter *manifestWriter);
......
......@@ -30,6 +30,7 @@
#include <KoInlineTextObjectManager.h>
#include <KoGenStyles.h>
#include <KoStyleManager.h>
#include <KoElementReference.h>
#include <KDebug>
#include <QTextDocument>
......@@ -54,7 +55,6 @@ public:
QTextFrame *textFrame;
QString label;
QString id;
QString author;
QDateTime date;
bool autoNumbering;
......@@ -101,11 +101,6 @@ void KoInlineNote::setAutoNumber(int autoNumber)
}
}
void KoInlineNote::setId(const QString &id)
{
d->id = id;
}
QTextFrame *KoInlineNote::textFrame() const
{
return d->textFrame;
......@@ -116,11 +111,6 @@ QString KoInlineNote::label() const
return d->label;
}
QString KoInlineNote::id() const
{
return d->id;
}
bool KoInlineNote::autoNumbering() const
{
return d->autoNumbering;
......@@ -207,7 +197,6 @@ bool KoInlineNote::loadOdf(const KoXmlElement & element, KoShapeLoadingContext &
return false;
}
d->id = element.attributeNS(KoXmlNS::text, "id");
for (KoXmlNode node = element.firstChild(); !node.isNull(); node = node.nextSibling()) {
KoXmlElement ts = node.toElement();
if (ts.namespaceURI() != KoXmlNS::text)
......@@ -246,7 +235,7 @@ void KoInlineNote::saveOdf(KoShapeSavingContext & context)
} else {
writer->addAttribute("text:note-class", "endnote");
}
writer->addAttribute("text:id", d->id);
writer->startElement("text:note-citation", false);
if (!autoNumbering()) {
writer->addAttribute("text:label", d->label);
......
......@@ -72,21 +72,12 @@ public:
*/
void setAutoNumber(int autoNumber);
/**
* Set the id that is used to reference this note.
* @param id the new id
*/
void setId(const QString &id);
/// return the current text
QTextFrame *textFrame() const;
/// return the current label
QString label() const;
/// return the current id
QString id() const;
/**
* @return whether the label should be automatically recreated or if the label is static.
*/
......
......@@ -187,6 +187,7 @@ public:
/// return the inline-object Id that is assigned for this object.
int id() const;
/// Set the inline-object Id that is assigned for this object by the KoInlineTextObjectManager.
void setId(int id);
......
......@@ -314,7 +314,7 @@ void KoTextAnchor::paint(QPainter &painter, QPaintDevice *, const QTextDocument
KoChangeTracker *changeTracker = KoTextDocument(document).changeTracker();
if (!changeTracker)
return;
KoChangeTrackerElement *changeElement = changeTracker->elementById(changeId);
if (changeElement && changeElement->getChangeType() == KoGenChange::DeleteChange) {
changePen.setColor(changeTracker->getDeletionBgColor());
......
......@@ -211,3 +211,9 @@ KoTextBlockPaintStrategyBase *KoTextBlockData::paintStrategy() const
{
return d->paintStrategy;
}
bool KoTextBlockData::saveXmlID() const
{
// as suggested by boemann, http://lists.kde.org/?l=calligra-devel&m=132396354701553&w=2