summaryrefslogtreecommitdiffstats
path: root/karbon/plugins/insertknots
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /karbon/plugins/insertknots
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'karbon/plugins/insertknots')
-rw-r--r--karbon/plugins/insertknots/Makefile.am15
-rw-r--r--karbon/plugins/insertknots/insertknotsplugin.cc118
-rw-r--r--karbon/plugins/insertknots/insertknotsplugin.h75
-rw-r--r--karbon/plugins/insertknots/insertknotsplugin.rc11
4 files changed, 219 insertions, 0 deletions
diff --git a/karbon/plugins/insertknots/Makefile.am b/karbon/plugins/insertknots/Makefile.am
new file mode 100644
index 00000000..9f76a527
--- /dev/null
+++ b/karbon/plugins/insertknots/Makefile.am
@@ -0,0 +1,15 @@
+INCLUDES = $(KOFFICE_INCLUDES) -I$(top_srcdir)/karbon -I$(top_srcdir)/karbon/core $(all_includes)
+
+kde_module_LTLIBRARIES = karbon_insertknotsplugin.la
+
+karbon_insertknotsplugin_la_SOURCES = insertknotsplugin.cc
+karbon_insertknotsplugin_la_LIBADD = $(LIB_KPARTS) \
+ ../../libkarboncommon.la
+
+karbon_insertknotsplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+
+partpluginsdir = $(kde_datadir)/karbon/kpartplugins
+partplugins_DATA = insertknotsplugin.rc
+
+METASOURCES = AUTO
+
diff --git a/karbon/plugins/insertknots/insertknotsplugin.cc b/karbon/plugins/insertknots/insertknotsplugin.cc
new file mode 100644
index 00000000..2d470b88
--- /dev/null
+++ b/karbon/plugins/insertknots/insertknotsplugin.cc
@@ -0,0 +1,118 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002, The Karbon Developers
+
+ 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 "insertknotsplugin.h"
+#include <karbon_view.h>
+#include <karbon_part.h>
+#include <core/vpath.h>
+#include <core/vsegment.h>
+#include <kgenericfactory.h>
+#include <kdebug.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+
+#include <knuminput.h>
+
+typedef KGenericFactory<InsertKnotsPlugin, KarbonView> InsertKnotsPluginFactory;
+K_EXPORT_COMPONENT_FACTORY( karbon_insertknotsplugin, InsertKnotsPluginFactory( "karboninsertknotsplugin" ) )
+
+InsertKnotsPlugin::InsertKnotsPlugin( KarbonView *parent, const char* name, const QStringList & ) : Plugin( parent, name )
+{
+ new KAction(
+ i18n( "&Insert Knots..." ), "14_insertknots", 0, this,
+ SLOT( slotInsertKnots() ), actionCollection(), "path_insert_knots" );
+
+ m_insertKnotsDlg = new VInsertKnotsDlg();
+}
+
+void
+InsertKnotsPlugin::slotInsertKnots()
+{
+ KarbonPart *part = ((KarbonView *)parent())->part();
+ if( part && m_insertKnotsDlg->exec() )
+ part->addCommand( new VInsertKnotsCmd( &part->document(), m_insertKnotsDlg->knots() ), true );
+}
+
+VInsertKnotsDlg::VInsertKnotsDlg( QWidget* parent, const char* name )
+ : KDialogBase( parent, name, true, i18n( "Insert Knots" ), Ok | Cancel )
+{
+ // add input fields:
+ QGroupBox* group = new QGroupBox( 2, Qt::Horizontal, i18n( "Properties" ), this );
+
+ new QLabel( i18n( "Knots:" ), group );
+ m_knots = new KIntSpinBox( group );
+ m_knots->setMinValue( 1 );
+ group->setMinimumWidth( 300 );
+
+ // signals and slots:
+ connect( this, SIGNAL( okClicked() ), this, SLOT( accept() ) );
+ connect( this, SIGNAL( cancelClicked() ), this, SLOT( reject() ) );
+
+ setMainWidget( group );
+ setFixedSize( baseSize() );
+}
+
+uint
+VInsertKnotsDlg::knots() const
+{
+ return m_knots->value();
+}
+
+void
+VInsertKnotsDlg::setKnots( uint value )
+{
+ m_knots->setValue( value );
+}
+
+
+VInsertKnotsCmd::VInsertKnotsCmd( VDocument* doc, uint knots )
+ : VReplacingCmd( doc, i18n( "Insert Knots" ) )
+{
+ m_knots = knots > 0 ? knots : 1;
+}
+
+void
+VInsertKnotsCmd::visitVSubpath( VSubpath& path )
+{
+ path.first();
+
+ double length;
+
+ // Ommit first segment.
+ while( path.next() )
+ {
+ length = path.current()->length();
+
+ for( uint i = m_knots; i > 0; --i )
+ {
+ path.insert(
+ path.current()->splitAt(
+ path.current()->lengthParam( length / ( m_knots + 1.0 ) ) ) );
+
+ path.next();
+ }
+
+ if( !success() )
+ setSuccess();
+ }
+}
+
+#include "insertknotsplugin.moc"
+
diff --git a/karbon/plugins/insertknots/insertknotsplugin.h b/karbon/plugins/insertknots/insertknotsplugin.h
new file mode 100644
index 00000000..89f0a4d0
--- /dev/null
+++ b/karbon/plugins/insertknots/insertknotsplugin.h
@@ -0,0 +1,75 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002, The Karbon Developers
+
+ 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 __INSERTKNOTSPLUGIN_H__
+#define __INSERTKNOTSPLUGIN_H__
+
+#include <kparts/plugin.h>
+#include <kdialogbase.h>
+#include <commands/vreplacingcmd.h>
+
+class VInsertKnotsDlg;
+class KarbonView;
+
+class InsertKnotsPlugin : public KParts::Plugin
+{
+ Q_OBJECT
+public:
+ InsertKnotsPlugin( KarbonView *parent, const char* name, const QStringList & );
+ virtual ~InsertKnotsPlugin() {}
+
+private slots:
+ void slotInsertKnots();
+
+private:
+ VInsertKnotsDlg *m_insertKnotsDlg;
+};
+
+class KIntSpinBox;
+
+class VInsertKnotsDlg : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ VInsertKnotsDlg( QWidget* parent = 0L, const char* name = 0L );
+
+ uint knots() const;
+ void setKnots( uint value );
+
+private:
+ KIntSpinBox* m_knots;
+};
+
+class VSubpath;
+
+class VInsertKnotsCmd : public VReplacingCmd
+{
+public:
+ VInsertKnotsCmd( VDocument* doc, uint knots );
+ virtual ~VInsertKnotsCmd() {}
+
+ virtual void visitVSubpath( VSubpath& path );
+
+protected:
+ uint m_knots;
+};
+
+#endif
+
diff --git a/karbon/plugins/insertknots/insertknotsplugin.rc b/karbon/plugins/insertknots/insertknotsplugin.rc
new file mode 100644
index 00000000..6572440c
--- /dev/null
+++ b/karbon/plugins/insertknots/insertknotsplugin.rc
@@ -0,0 +1,11 @@
+<!DOCTYPE kpartgui>
+<kpartplugin name="insertknotsplugin" library="karbon_insertknotsplugin">
+<MenuBar>
+ <Menu name="effects">
+ <Action name="path_insert_knots"/>
+ </Menu>
+</MenuBar>
+<ToolBar name="Effects" fullWidth="false">
+ <Action name="path_insert_knots"/>
+</ToolBar>
+</kpartplugin>