1 /* This file is part of the KDE project 2 * Copyright (C) 2007 Thomas Zander <zander@kde.org> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 #ifndef KOTEXTREFERENCE_H 20 #define KOTEXTREFERENCE_H 21 22 #include "KoVariable.h" 23 24 class KoTextLocator; 25 26 /** 27 * This variable displays information about a text reference. 28 * A user can insert characters that are called locators. And are represented by a KoTextLocator 29 * the user can then insert (several) KoTextReference variables that will update the textual description 30 * of the locator whenever text is re-layouted. 31 * This effectively means that the reference will print the page number (for example) of where the 32 * locator is and keep it updated automatically. 33 */ 34 class KoTextReference : public KoVariable 35 { 36 Q_OBJECT 37 public: 38 /** 39 * Constructor; please don't use directly as the KoInlineTextObjectManager will supply an action 40 * to create one. 41 * @param indexId the index of the inline object that is the locator. See KoInlineObject::id() 42 */ 43 explicit KoTextReference(int indexId); 44 ~KoTextReference() override; 45 46 void variableMoved(const QTextDocument *document, int posInDocument) override; 47 void setup() override; 48 bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context) override; 49 void saveOdf(KoShapeSavingContext &context) override; 50 51 private: 52 KoTextLocator *locator(); 53 int m_indexId; 54 // TODO store a config of what we actually want to show. The hardcoded pagenumber is not enough. 55 // we want 'section' / chapter name/number and maybe word. All in a nice formatted text. 56 // see also the ODF spec. 57 }; 58 59 #endif 60