Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Krita
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tusooa Zhu
Krita
Commits
33ba042e
Commit
33ba042e
authored
Jul 18, 2007
by
Pierre Ducroquet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Beginning for a pageVariable. Currently, only the page-count field is supported.
svn path=/trunk/koffice/; revision=689683
parent
7197b201
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
206 additions
and
9 deletions
+206
-9
libs/kotext/opendocument/KoTextLoader.cpp
libs/kotext/opendocument/KoTextLoader.cpp
+32
-9
plugins/variables/CMakeLists.txt
plugins/variables/CMakeLists.txt
+2
-0
plugins/variables/PageVariable.cpp
plugins/variables/PageVariable.cpp
+48
-0
plugins/variables/PageVariable.h
plugins/variables/PageVariable.h
+48
-0
plugins/variables/PageVariableFactory.cpp
plugins/variables/PageVariableFactory.cpp
+37
-0
plugins/variables/PageVariableFactory.h
plugins/variables/PageVariableFactory.h
+37
-0
plugins/variables/VariablesPlugin.cpp
plugins/variables/VariablesPlugin.cpp
+2
-0
No files found.
libs/kotext/opendocument/KoTextLoader.cpp
View file @
33ba042e
...
...
@@ -45,7 +45,6 @@
#include <KoInlineTextObjectManager.h>
#include <KoInlineObjectRegistry.h>
#include <KoProperties.h>
#include <KoVariable.h>
#include "../styles/KoStyleManager.h"
#include "../styles/KoParagraphStyle.h"
...
...
@@ -829,17 +828,17 @@ void KoTextLoader::loadSpan(KoTextLoadingContext& context, const KoXmlElement& p
dateFormat
=
dataFormat
.
prefix
+
dataFormat
.
formatStr
+
dataFormat
.
suffix
;
}
}
KoProperties
*
dateProperties
=
new
KoProperties
()
;
dateProperties
->
setProperty
(
"fixed"
,
QVariant
(
ts
.
attributeNS
(
KoXmlNS
::
text
,
"fixed"
)
==
"true"
));
dateProperties
->
setProperty
(
"time"
,
ts
.
attributeNS
(
KoXmlNS
::
text
,
localName
+
"-value"
));
dateProperties
->
setProperty
(
"definition"
,
dateFormat
);
dateProperties
->
setProperty
(
"adjust"
,
ts
.
attributeNS
(
KoXmlNS
::
text
,
localName
+
"-adjust"
));
KoProperties
dateProperties
;
dateProperties
.
setProperty
(
"fixed"
,
QVariant
(
ts
.
attributeNS
(
KoXmlNS
::
text
,
"fixed"
)
==
"true"
));
dateProperties
.
setProperty
(
"time"
,
ts
.
attributeNS
(
KoXmlNS
::
text
,
localName
+
"-value"
));
dateProperties
.
setProperty
(
"definition"
,
dateFormat
);
dateProperties
.
setProperty
(
"adjust"
,
ts
.
attributeNS
(
KoXmlNS
::
text
,
localName
+
"-adjust"
));
if
(
dateFormat
.
isEmpty
())
dateProperties
->
setProperty
(
"displayType"
,
localName
);
dateProperties
.
setProperty
(
"displayType"
,
localName
);
else
dateProperties
->
setProperty
(
"displayType"
,
"custom"
);
dateProperties
.
setProperty
(
"displayType"
,
"custom"
);
KoInlineObject
*
dateObject
=
dateFactory
->
createInlineObject
(
dateProperties
);
KoInlineObject
*
dateObject
=
dateFactory
->
createInlineObject
(
&
dateProperties
);
textObjectManager
->
insertInlineObject
(
cursor
,
dateObject
);
}
}
...
...
@@ -847,6 +846,30 @@ void KoTextLoader::loadSpan(KoTextLoadingContext& context, const KoXmlElement& p
}
}
}
else
if
(
isTextNS
&&
(
localName
==
"page-count"
||
localName
==
"page-number"
)
)
{
KoTextDocumentLayout
*
layout
=
dynamic_cast
<
KoTextDocumentLayout
*>
(
cursor
.
block
().
document
()
->
documentLayout
());
if
(
layout
)
{
KoInlineTextObjectManager
*
textObjectManager
=
layout
->
inlineObjectTextManager
();
if
(
textObjectManager
)
{
KoVariableManager
*
varManager
=
textObjectManager
->
variableManager
();
if
(
varManager
)
{
if
(
KoInlineObjectRegistry
::
instance
()
->
contains
(
"page"
))
{
KoInlineObjectFactory
*
pageFactory
=
KoInlineObjectRegistry
::
instance
()
->
value
(
"page"
);
if
(
pageFactory
)
{
KoProperties
props
;
if
(
localName
==
"page-count"
)
props
.
setProperty
(
"count"
,
true
);
else
props
.
setProperty
(
"count"
,
false
);
KoInlineObject
*
pageObject
=
pageFactory
->
createInlineObject
(
&
props
);
textObjectManager
->
insertInlineObject
(
cursor
,
pageObject
);
}
}
}
}
}
}
else
{
#if 0 //1.6:
...
...
plugins/variables/CMakeLists.txt
View file @
33ba042e
...
...
@@ -7,6 +7,8 @@ set(textvariables_SRCS
DateVariable.cpp
DateVariableFactory.cpp
FixedDateFormat.cpp
PageVariable.cpp
PageVariableFactory.cpp
)
...
...
plugins/variables/PageVariable.cpp
0 → 100644
View file @
33ba042e
/* This file is part of the KDE project
* Copyright (C) 2007 Pierre Ducroquet <pinaraf@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "PageVariable.h"
#include <KoProperties.h>
#include <kdebug.h>
#include <KoDocument.h>
PageVariable
::
PageVariable
()
:
KoVariable
(
true
),
m_type
(
PageCount
)
{
}
void
PageVariable
::
setProperties
(
const
KoProperties
*
props
)
{
// Nothing to be done here ?
if
(
props
->
boolProperty
(
"count"
))
{
m_type
=
PageCount
;
}
else
{
m_type
=
PageNumber
;
}
}
void
PageVariable
::
propertyChanged
(
Property
property
,
const
QVariant
&
value
)
{
if
((
property
==
KoInlineObject
::
PageCount
)
&&
(
m_type
==
PageCount
))
{
setValue
(
value
.
toString
());
}
// else if ((property == KoInlineObject::StartPage) && (m_type == PageNumber)) {
// setValue(value.toString());
//}
//TODO: support for the PageNumber...
}
plugins/variables/PageVariable.h
0 → 100644
View file @
33ba042e
/* This file is part of the KDE project
* Copyright (C) 2007 Pierre Ducroquet <pinaraf@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef PAGEVARIABLE_H
#define PAGEVARIABLE_H
#include <KoVariable.h>
#include <QString>
/**
* This is a KoVariable for page numbers.
*/
class
PageVariable
:
public
KoVariable
{
public:
enum
PageType
{
PageCount
,
PageNumber
};
/**
* Constructor.
*/
PageVariable
();
void
setProperties
(
const
KoProperties
*
props
);
void
propertyChanged
(
Property
property
,
const
QVariant
&
value
);
private:
PageType
m_type
;
};
#endif
plugins/variables/PageVariableFactory.cpp
0 → 100644
View file @
33ba042e
/* This file is part of the KDE project
* Copyright (C) 2007 Pierre Ducroquet <pinaraf@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "PageVariableFactory.h"
#include "PageVariable.h"
#include <KoProperties.h>
#include <kdebug.h>
PageVariableFactory
::
PageVariableFactory
(
QObject
*
parent
)
:
KoInlineObjectFactory
(
parent
,
"page"
)
{
// Nothing
kDebug
()
<<
"Creating the page variable factory"
<<
endl
;
}
KoInlineObject
*
PageVariableFactory
::
createInlineObject
(
const
KoProperties
*
properties
)
const
{
PageVariable
*
var
=
new
PageVariable
;
var
->
setProperties
(
properties
);
return
var
;
}
plugins/variables/PageVariableFactory.h
0 → 100644
View file @
33ba042e
/* This file is part of the KDE project
* Copyright (C) 2007 Pierre Ducroquet <pinaraf@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KO_PAGE_VARIABLE_FACTORY
#define KO_PAGE_VARIABLE_FACTORY
#include <KoInlineObjectFactory.h>
class
KoVariable
;
class
PageVariableFactory
:
public
KoInlineObjectFactory
{
public:
explicit
PageVariableFactory
(
QObject
*
parent
);
~
PageVariableFactory
()
{}
KoInlineObject
*
createInlineObject
(
const
KoProperties
*
properties
)
const
;
ObjectType
type
()
const
{
return
TextVariable
;
}
};
#endif
plugins/variables/VariablesPlugin.cpp
View file @
33ba042e
...
...
@@ -18,6 +18,7 @@
*/
#include "VariablesPlugin.h"
#include "DateVariableFactory.h"
#include "PageVariableFactory.h"
#include <kgenericfactory.h>
#include <KoInlineObjectRegistry.h>
...
...
@@ -28,6 +29,7 @@ K_EXPORT_COMPONENT_FACTORY(textvariables,
VariablesPlugin
::
VariablesPlugin
(
QObject
*
parent
,
const
QStringList
&
)
:
QObject
(
parent
)
{
KoInlineObjectRegistry
::
instance
()
->
add
(
new
PageVariableFactory
(
parent
));
KoInlineObjectRegistry
::
instance
()
->
add
(
new
DateVariableFactory
(
parent
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment