View Issue Details

IDProjectCategoryView StatusLast Update
0010730ScribusUsabilitypublic2012-12-03 11:53
Reportercezaryece Assigned Tocbradney  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Product Version1.5.0svn 
Fixed in Version1.5.0svn 
Summary0010730: [new feature] footnotes ready for testing
DescriptionFootnotes feature is ready for testing for who has access to Scribus GIT repository.
To obtain footnotes branch from git run these commands:

mkdir footnotes
cd footnotes
git init
git remote add -t footnotes -f origin git@scribus.net:scribus.git
git checkout footnotes

and then build Scribus from source as usual you do.

Footnotes branch contain whole code for marks feature (previously uploaded as patch in http://bugs.scribus.net/view.php?id=10428 report), as it is on top of it. So, you can test marks (variable text, cross-references) and footnotes/endnotes as well.

While testing please run Scribus under debuger and log here any crashes and freezes with proper debuger trace information or steps to reproduce problematic behaviour.

Footnotes feature is in quite mature state (as I think) and someone familiar with odt/doc file formats can start working on importing notes information from text files.
Feel free for asking me for technical details on IRC, ML or via email (cezaryece at oferuje.pl)
TagsNo tags attached.
Patch

Relationships

child of 0003349 acknowledgedcezaryece A real support of footnotes 

Activities

ale

2012-06-05 14:48

manager   ~0028081

compiled and run: nice work, cezary!

some first feedback from my part:

- if there is only one type of footnotes (and this is what most people will want), i don't think that there is a need to show the dialog with the types. if the dialog is always shown, it should have a button to create new types (we should have such a button for every type of resources, btw!)

- there should be a character style for the note in the text and one in
the notes (they could have different sizes)

- when "auto height" is chosen, we should have a choice to let the notes area to grow inside of the frame (upwards) or append it to it (downwards)

- if there is a "new name" field, it should always be editable

but all in all, what i see is really good!

cezaryece

2012-06-05 21:51

updater   ~0028092

ad. 1 agree
ad. 2 isn`t? you have character style for marks in text and paragraph style for notes
ad. 3 don`t understand
ad. 4 should be, where it does not now?

ale

2012-06-06 06:38

manager   ~0028094

hi cezary,
one notice: the four points above are non blocking! the footnotes worked well for me... they are more ideas that could make the tool perfect :-)

2. in some case you may need a character style for the mark in the text and one character style for the mark in the notes. they mostly have the same formatting, but they don't have to (the one in the notes could be bold... or they could have different sizes).

3. when you type some text in the notes frame, the text field grows "down the page". in some cases (i think of magazines...) you may want to set a fix height for the "whole" frame (notes included) and when you type the text in the notes area, you will make the main frame shorter. that way, the full column will always be correct and the exceeding text will flow into the next main frame

4. it is grayed out. it's only active when one creates a new "set". again... not so important...

cbradney

2012-06-06 07:15

administrator   ~0028097

ale, please test this so its production ready, not half ready or almost ready. consider it needs to go into stable rather than development. We need to get 1.5 sorted.

cezaryece

2012-06-06 09:37

updater   ~0028098

ad.3 I was thinking about that, but it is potentially dangerous as can go to infinite loop when mark for note is in last line of text and after note frame grow it should go to next frame and then note frame shrinks and again is place for line with mark, so note frame grow...
Avoiding this case is not complicated in fact (just not grow notes frame to top if it moves marks to next frame), but provide some not consequential design.
So... let user decide and do it manually.

ale

2012-06-06 12:34

manager   ~0028101

craig, what i've seen until now looks solid.

i think that cedric is also looking at it.

as soon as i've understood how to get a diff of the branch out of git, i will also have a look at the code...
i'm slowly getting used to it.

we need people testing it. fore sure! but until undo is not finished, there won't be many people working with 1.5svn... most of all, not on longer documents which may need footnotes.

i will do more tests in the next days. and document them!

cezaryece

2012-06-18 09:17

updater   ~0028181

Craig, I have upload patch created from my branch repo after syncing it with last SVN 17580 revision.

cezaryece

2012-06-21 13:41

updater  

footnotes.diff (360,424 bytes)   
diff --git a/Scribus/Scribus.pro b/Scribus/Scribus.pro
index 39781ed..4bf4d07 100644
--- a/Scribus/Scribus.pro
+++ b/Scribus/Scribus.pro
@@ -1077,7 +1077,18 @@ HEADERS += scribus/actionmanager.h \
            scribus/styles/cellstyle.attrdefs.cxx \
            scribus/main_nix.cpp \
            scribus/main_win32.cpp \
-           scribus/styles/linestyle.attrdefs.cxx
+           scribus/styles/linestyle.attrdefs.cxx \
+    scribus/marks.h \
+    scribus/notesset.h \
+    scribus/pageitem_noteframe.h \
+    scribus/ui/notessetmanager.h \
+    scribus/ui/markvariabletext.h \
+    scribus/ui/marksmanager.h \
+    scribus/ui/marknote.h \
+    scribus/ui/MarkInsertDlg.h \
+    scribus/ui/markanchor.h \
+    scribus/ui/mark2mark.h \
+    scribus/ui/mark2item.h
 FORMS += scribus/ui/aboutplugins.ui \
          scribus/ui/aligndistribute.ui \
          scribus/ui/arcvectorbase.ui \
@@ -1201,7 +1212,14 @@ FORMS += scribus/ui/aboutplugins.ui \
          scribus/plugins/tools/spellcheck/aspellpluginbase.ui \
          scribus/plugins/scripter/python/sceditor/mainwindow.ui \
          scribus/plugins/tools/2geomtools/meshdistortion/meshdistortiondialog.ui \
-         scribus/plugins/tools/2geomtools/pathalongpath/pathdialogbase.ui
+         scribus/plugins/tools/2geomtools/pathalongpath/pathdialogbase.ui \
+    scribus/ui/notessetmanager.ui \
+    scribus/ui/markvariabletext.ui \
+    scribus/ui/marksmanager.ui \
+    scribus/ui/marknote.ui \
+    scribus/ui/markanchor.ui \
+    scribus/ui/mark2mark.ui \
+    scribus/ui/mark2item.ui
 SOURCES += scribus/actionmanager.cpp \
            scribus/canvas.cpp \
            scribus/canvasgesture_cellselect.cpp \
@@ -2074,7 +2092,16 @@ SOURCES += scribus/actionmanager.cpp \
            scribus/plugins/tools/2geomtools/meshdistortion/meshdistortion.cpp \
            scribus/plugins/tools/2geomtools/meshdistortion/meshdistortiondialog.cpp \
            scribus/plugins/tools/2geomtools/pathalongpath/pathalongpath.cpp \
-           scribus/plugins/tools/2geomtools/pathalongpath/pathdialog.cpp
+           scribus/plugins/tools/2geomtools/pathalongpath/pathdialog.cpp \
+    scribus/notesset.cpp \
+    scribus/pageitem_noteframe.cpp \
+    scribus/ui/mark2item.cpp \
+    scribus/ui/notessetmanager.cpp \
+    scribus/ui/markvariabletext.cpp \
+    scribus/ui/marksmanager.cpp \
+    scribus/ui/marknote.cpp \
+    scribus/ui/markanchor.cpp \
+    scribus/ui/mark2mark.cpp
 RESOURCES += scribus/plugins/scripter/python/sceditor/dockwidget_icons.qrc
 TRANSLATIONS += resources/translations/po/scribus.af.ts \
                 resources/translations/po/scribus.ar.ts \
diff --git a/Scribus/Scribus.pro.user b/Scribus/Scribus.pro.user
new file mode 100644
index 0000000..5ca081f
--- /dev/null
+++ b/Scribus/Scribus.pro.user
@@ -0,0 +1,268 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE QtCreatorProject>
+<!-- Written by Qt Creator 2.5.0, 2012-06-21T14:07:16. -->
+<qtcreator>
+ <data>
+  <variable>ProjectExplorer.Project.ActiveTarget</variable>
+  <value type="int">0</value>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.EditorSettings</variable>
+  <valuemap type="QVariantMap">
+   <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
+   <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
+   <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
+   <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
+    <value type="QString" key="language">Cpp</value>
+    <valuemap type="QVariantMap" key="value">
+     <value type="QString" key="CurrentPreferences">CppGlobal</value>
+    </valuemap>
+   </valuemap>
+   <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
+    <value type="QString" key="language">QmlJS</value>
+    <valuemap type="QVariantMap" key="value">
+     <value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
+    </valuemap>
+   </valuemap>
+   <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
+   <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
+   <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
+   <value type="int" key="EditorConfiguration.IndentSize">4</value>
+   <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
+   <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
+   <value type="int" key="EditorConfiguration.PaddingMode">1</value>
+   <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
+   <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
+   <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
+   <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
+   <value type="int" key="EditorConfiguration.TabSize">8</value>
+   <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
+   <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
+   <value type="bool" key="EditorConfiguration.addFinalNewLine">false</value>
+   <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
+   <value type="bool" key="EditorConfiguration.cleanWhitespace">false</value>
+   <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
+  </valuemap>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.PluginSettings</variable>
+  <valuemap type="QVariantMap"/>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.Target.0</variable>
+  <valuemap type="QVariantMap">
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Target.DesktopTarget</value>
+   <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
+   <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
+   <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">1</value>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
+    <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:{754012d6-2dac-4067-8e89-cbb0c3b1e6b6}</value>
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProcessStep.Arguments"></value>
+      <value type="QString" key="ProjectExplorer.ProcessStep.Command">/home/czarek/GIT/scribus/debug</value>
+      <value type="QString" key="ProjectExplorer.ProcessStep.WorkingDirectory">/home/czarek/GIT/scribus</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Process Step</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.ProcessStep</value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+    </valuemap>
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+    </valuemap>
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.1 (System) Release</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
+    <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/czarek/GIT/scribus/BUILD</value>
+    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">2</value>
+    <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+   </valuemap>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
+    <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:{754012d6-2dac-4067-8e89-cbb0c3b1e6b6}</value>
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProcessStep.Arguments"></value>
+      <value type="QString" key="ProjectExplorer.ProcessStep.Command">/home/czarek/GIT/scribus/debug</value>
+      <value type="QString" key="ProjectExplorer.ProcessStep.WorkingDirectory">/home/czarek/GIT/scribus</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Process Step</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.ProcessStep</value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+    </valuemap>
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+     </valuemap>
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+    </valuemap>
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.1 (System) Debug</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
+    <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/czarek/GIT/scribus/BUILD</value>
+    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">2</value>
+    <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+   </valuemap>
+   <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
+    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
+    </valuemap>
+    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
+   </valuemap>
+   <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
+    <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
+    <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
+    <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
+    <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
+    <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
+    <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
+    <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
+     <value type="int">0</value>
+     <value type="int">1</value>
+     <value type="int">2</value>
+     <value type="int">3</value>
+     <value type="int">4</value>
+     <value type="int">5</value>
+     <value type="int">6</value>
+     <value type="int">7</value>
+     <value type="int">8</value>
+     <value type="int">9</value>
+     <value type="int">10</value>
+     <value type="int">11</value>
+     <value type="int">12</value>
+     <value type="int">13</value>
+     <value type="int">14</value>
+    </valuelist>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Scribus</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration</value>
+    <value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value>
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">Scribus.pro</value>
+    <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
+    <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
+    <valuelist type="QVariantList" key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges"/>
+    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
+    <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
+    <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
+    <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
+    <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
+   </valuemap>
+   <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
+    <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
+    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
+    <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
+    <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
+    <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
+    <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
+    <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
+    <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
+    <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
+     <value type="int">0</value>
+     <value type="int">1</value>
+     <value type="int">2</value>
+     <value type="int">3</value>
+     <value type="int">4</value>
+     <value type="int">5</value>
+     <value type="int">6</value>
+     <value type="int">7</value>
+     <value type="int">8</value>
+     <value type="int">9</value>
+     <value type="int">10</value>
+     <value type="int">11</value>
+     <value type="int">12</value>
+     <value type="int">13</value>
+     <value type="int">14</value>
+    </valuelist>
+    <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
+    <value type="int" key="ProjectExplorer.CustomExecutableRunConfiguration.BaseEnvironmentBase">2</value>
+    <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">/home/czarek/GIT/scribus/INSTALL/bin/scribus</value>
+    <value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">false</value>
+    <valuelist type="QVariantList" key="ProjectExplorer.CustomExecutableRunConfiguration.UserEnvironmentChanges"/>
+    <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">/home/czarek/GIT/scribus/INSTALL</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Run /home/czarek/GIT/scribus/INSTALL/bin/scribus</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
+    <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
+    <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
+    <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
+    <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
+   </valuemap>
+   <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">2</value>
+  </valuemap>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.TargetCount</variable>
+  <value type="int">1</value>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
+  <value type="QString">{a46212d7-d9c2-4a37-a057-ff399f0b7fea}</value>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
+  <value type="int">11</value>
+ </data>
+</qtcreator>
diff --git a/Scribus/cmake/modules/FindPOPPLER.cmake b/Scribus/cmake/modules/FindPOPPLER.cmake
index 873527e..72273cf 100644
--- a/Scribus/cmake/modules/FindPOPPLER.cmake
+++ b/Scribus/cmake/modules/FindPOPPLER.cmake
@@ -16,7 +16,7 @@ FIND_PATH(POPPLER_INCLUDE_DIR
 
 FIND_LIBRARY(POPPLER_LIBRARY
   NAMES libpoppler poppler
-  PATHS ${PKG_POPPLER_LIBRARIES} ${POPPLER_LIBRARY_DIRS} /usr/local/lib /usr/lib
+  PATHS ${PKG_POPPLER_LIBRARIES} ${POPPLER_LIBRARY_DIRS} /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu
   NO_DEFAULT_PATH
 )
 IF (POPPLER_LIBRARY)
diff --git a/Scribus/scribus/CMakeLists.txt b/Scribus/scribus/CMakeLists.txt
index c7e9605..cd75fdb 100644
--- a/Scribus/scribus/CMakeLists.txt
+++ b/Scribus/scribus/CMakeLists.txt
@@ -85,11 +85,18 @@ SET(SCRIBUS_UI_SRC
   ui/inserttablerowsdialog.ui
   ui/latexeditor.ui
   ui/newmarginwidgetbase.ui
+ui/mark2item.ui
+ui/mark2mark.ui
+ui/markanchor.ui
+ui/marknote.ui
+ui/markvariabletext.ui
+ui/marksmanager.ui
   ui/measurementsbase.ui
   ui/multipleduplicate.ui
   ui/multiprogressdialog.ui
   ui/nftdialog.ui
   ui/nftwidget.ui
+ui/notessetmanager.ui
   ui/pageitemattributes.ui
   ui/pagepalette_pagesbase.ui
   ui/pagepalette_masterpagesbase.ui
@@ -209,6 +216,8 @@ SET(SCRIBUS_MOC_CLASSES
   latexhelpers.h
   loadsaveplugin.h
   menumanager.h
+marks.h
+notesset.h
   navigator.h
   observable.h
   pageitem.h
@@ -225,6 +234,7 @@ SET(SCRIBUS_MOC_CLASSES
   pageitem_symbol.h
   pageitem_table.h
   pageitem_textframe.h
+pageitem_noteframe.h
   pageitempointer.h
   pdf_analyzer.h
   pdflib.h
@@ -316,6 +326,13 @@ SET(SCRIBUS_MOC_CLASSES
   ui/latexeditor.h
   ui/layers.h
   ui/loremipsum.h
+ui/MarkInsertDlg.h
+ui/mark2item.h
+ui/mark2mark.h
+ui/markanchor.h
+ui/marknote.h
+ui/markvariabletext.h
+ui/marksmanager.h
   ui/margindialog.h
   ui/marginpresetlayout.h
   ui/marginwidget.h
@@ -331,6 +348,7 @@ SET(SCRIBUS_MOC_CLASSES
   ui/nftdialog.h
   ui/nftwidget.h
   ui/nodeeditpalette.h
+ui/notessetmanager.h
   ui/oneclick.h
   ui/outlinepalette.h
   ui/pageitemattributes.h
@@ -562,6 +580,7 @@ SET(SCRIBUS_SOURCES
   nftrcreader.cpp
   nftsettings.cpp
   nfttemplate.cpp
+notesset.cpp
   pageitem.cpp
   pageitem_arc.cpp
   pageitem_group.cpp
@@ -576,6 +595,7 @@ SET(SCRIBUS_SOURCES
   pageitem_symbol.cpp
   pageitem_table.cpp
   pageitem_textframe.cpp
+pageitem_noteframe.cpp
   pageitempointer.cpp
   pagesize.cpp
   pdf_analyzer.cpp
@@ -747,6 +767,12 @@ SET(SCRIBUS_SOURCES
   ui/linecombo.cpp
   ui/linkbutton.cpp
   ui/loremipsum.cpp
+ui/mark2item.cpp
+ui/mark2mark.cpp
+ui/markanchor.cpp
+ui/marknote.cpp
+ui/markvariabletext.cpp
+ui/marksmanager.cpp
   ui/margindialog.cpp
   ui/marginpresetlayout.cpp
   ui/marginwidget.cpp
@@ -762,6 +788,7 @@ SET(SCRIBUS_SOURCES
   ui/nftdialog.cpp
   ui/nftwidget.cpp
   ui/nodeeditpalette.cpp
+ui/notessetmanager.cpp
   ui/oneclick.cpp
   ui/outlinepalette.cpp
   ui/pageitemattributes.cpp
diff --git a/Scribus/scribus/actionmanager.cpp b/Scribus/scribus/actionmanager.cpp
index c777763..6e212c9 100644
--- a/Scribus/scribus/actionmanager.cpp
+++ b/Scribus/scribus/actionmanager.cpp
@@ -240,8 +240,14 @@ void ActionManager::initEditMenuActions()
 	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
 	name="editJavascripts";
 	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	name="editMarks";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	name="editNotesSets";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
 
 	(*scrActions)["editStyles"]->setToggleAction(true);
+	(*scrActions)["editMarks"]->setToggleAction(true);
+	(*scrActions)["editNotesSets"]->setToggleAction(true);
 
 	connect( (*scrActions)["editUndoAction"], SIGNAL(triggeredData(int)) , undoManager, SLOT(undo(int)) );
 	connect( (*scrActions)["editRedoAction"], SIGNAL(triggeredData(int)) , undoManager, SLOT(redo(int)) );
@@ -542,10 +548,45 @@ void ActionManager::initInsertMenuActions()
 	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
 	(*scrActions)["stickyTools"]->setToggleAction(true);
 
+	//Marks
+	name="insertMarkAnchor";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	(*scrActions)[name]->setEnabled(true);
+	name="insertMarkVariableText";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	(*scrActions)[name]->setEnabled(true);
+	name="insertMarkItem";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	(*scrActions)[name]->setEnabled(true);
+	name="insertMark2Mark";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	(*scrActions)[name]->setEnabled(true);
+	name="insertMarkNote";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	(*scrActions)[name]->setEnabled(true);
+//	name="insertMarkIndex";
+//	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+//	(*scrActions)[name]->setEnabled(true);
+	name="editMark";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	(*scrActions)[name]->setEnabled(false);
+	name="itemUpdateMarks";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	(*scrActions)[name]->setEnabled(false);
+
 	connect( (*scrActions)["insertFrame"], SIGNAL(triggered()), mainWindow, SLOT(slotInsertFrame()) );
 	connect( (*scrActions)["insertGlyph"], SIGNAL(triggered()), mainWindow, SLOT(slotCharSelect()) );
 	connect( (*scrActions)["insertSampleText"], SIGNAL(triggered()), mainWindow, SLOT(insertSampleText()) );
 	connect( (*scrActions)["stickyTools"], SIGNAL(triggered()), mainWindow, SLOT(ToggleStickyTools()) );
+
+	connect( (*scrActions)["insertMarkAnchor"], SIGNAL(triggered()), mainWindow, SLOT(slotInsertMarkAnchor()) );
+	connect( (*scrActions)["insertMarkVariableText"], SIGNAL(triggered()), mainWindow, SLOT(slotInsertMarkVariableText()) );
+	connect( (*scrActions)["insertMarkItem"], SIGNAL(triggered()), mainWindow, SLOT(slotInsertMarkItem()) );
+	connect( (*scrActions)["insertMark2Mark"], SIGNAL(triggered()), mainWindow, SLOT(slotInsertMark2Mark()) );
+	connect( (*scrActions)["insertMarkNote"], SIGNAL(triggered()), mainWindow, SLOT(slotInsertMarkNote()) );
+//	connect( (*scrActions)["insertMarkIndex"], SIGNAL(triggered()), mainWindow, SLOT(slotInsertMarkIndex()) );
+	connect( (*scrActions)["editMark"], SIGNAL(triggered()), mainWindow, SLOT(slotEditMark()) );
+	connect( (*scrActions)["itemUpdateMarks"], SIGNAL(triggered()), mainWindow, SLOT(slotUpdateMarks()) );
 }
 
 void ActionManager::initPageMenuActions()
@@ -1403,6 +1444,8 @@ void ActionManager::languageChange()
 //	(*scrActions)["editPatterns"]->setTexts( tr("Patterns..."));
 //	(*scrActions)["editGradients"]->setTexts( tr("Gradients..."));
 	(*scrActions)["editStyles"]->setTexts( tr("S&tyles..."));
+	(*scrActions)["editMarks"]->setTexts( tr("Marks..."));
+	(*scrActions)["editNotesSets"]->setTexts( tr("Notes Sets..."));
 	(*scrActions)["editMasterPages"]->setTexts( tr("&Master Pages..."));
 	(*scrActions)["editJavascripts"]->setTexts( tr("&JavaScripts..."));
 
@@ -1498,6 +1541,14 @@ void ActionManager::languageChange()
 	(*scrActions)["insertGlyph"]->setTexts( tr("&Glyph..."));
 	(*scrActions)["insertSampleText"]->setTexts( tr("Sample Text"));
 	(*scrActions)["stickyTools"]->setTexts( tr("Sticky Tools"));
+	(*scrActions)["insertMarkAnchor"]->setTexts( tr("Anchor Mark"));
+	(*scrActions)["insertMarkVariableText"]->setTexts( tr("Variable Text"));
+	(*scrActions)["insertMarkItem"]->setTexts( tr("Reference to Item"));
+	(*scrActions)["insertMark2Mark"]->setTexts( tr("Reference to Mark"));
+	(*scrActions)["insertMarkNote"]->setTexts( tr("Foot/Endnote"));
+//	(*scrActions)["insertMarkIndex"]->setTexts( tr("Index entry"));
+	(*scrActions)["editMark"]->setTexts( tr("Edit Mark"));
+	(*scrActions)["itemUpdateMarks"]->setTexts( tr("Update Marks"));
 
 	//Page menu
 	(*scrActions)["pageInsert"]->setTexts( tr("&Insert..."));
@@ -1888,6 +1939,8 @@ void ActionManager::createDefaultMenus()
 		<< "editReplaceColors"
 //		<< "editPatterns"
 		<< "editStyles"
+		<< "editMarks"
+		<< "editNotesSets"
 		<< "editMasterPages"
 		<< "editJavascripts";
 	//Style
@@ -1993,7 +2046,15 @@ void ActionManager::createDefaultMenus()
 		<< "toolsInsertRenderFrame"
 		<< "stickyTools"
 		<< "insertGlyph"
-		<< "insertSampleText";
+		<< "insertSampleText"
+		<< "insertMarkAnchor"
+		<< "insertMarkVariableText"
+		<< "insertMarkItem"
+		<< "insertMark2Mark"
+		<< "insertMarkNote"
+		<< "insertMarkIndex"
+		<< "editMark"
+		<< "itemUpdateMarks";
 
 	itmenu->second
 		<< "unicodeSoftHyphen"
diff --git a/Scribus/scribus/canvas.cpp b/Scribus/scribus/canvas.cpp
index 762d49f..96bb750 100644
--- a/Scribus/scribus/canvas.cpp
+++ b/Scribus/scribus/canvas.cpp
@@ -1034,7 +1034,10 @@ void Canvas::drawContents(QPainter *psx, int clipx, int clipy, int clipw, int cl
 					{
 						DrawMasterItems(painter, m_doc->Pages->at(a), layer, QRect(clipx, clipy, clipw, cliph));
 					}
-					DrawPageItems(painter, layer, QRect(clipx, clipy, clipw, cliph));
+					//first pass draws all except notes frames
+					DrawPageItems(painter, layer, QRect(clipx, clipy, clipw, cliph), false);
+					//seconf only for notes frames
+					DrawPageItems(painter, layer, QRect(clipx, clipy, clipw, cliph), true);
 				}
 			}
 		}
@@ -1075,7 +1078,10 @@ void Canvas::drawContents(QPainter *psx, int clipx, int clipy, int clipw, int cl
 				for (int layerLevel = 0; layerLevel < layerCount; ++layerLevel)
 				{
 					m_doc->Layers.levelToLayer(layer, layerLevel);
-					DrawPageItems(painter, layer, QRect(clipx, clipy, clipw, cliph));
+					//first pass draws all except notes frames
+					DrawPageItems(painter, layer, QRect(clipx, clipy, clipw, cliph), false);
+					//second pass draw only notes frames
+					DrawPageItems(painter, layer, QRect(clipx, clipy, clipw, cliph), true);
 				}
 			}
 		}
@@ -1444,8 +1450,10 @@ void Canvas::DrawMasterItems(ScPainter *painter, ScPage *page, ScLayer& layer, Q
 /**
   draws page items contained in a specific Layer
  */
-void Canvas::DrawPageItems(ScPainter *painter, ScLayer& layer, QRect clip)
+void Canvas::DrawPageItems(ScPainter *painter, ScLayer& layer, QRect clip, bool notesFramesPass)
 {
+	if (notesFramesPass && m_doc->m_docNotesList.isEmpty())
+		return;
 	if ((m_viewMode.previewMode) && (!layer.isPrintable))
 		return;
 	if ((m_viewMode.viewAsPreview) && (!layer.isPrintable))
@@ -1465,9 +1473,34 @@ void Canvas::DrawPageItems(ScPainter *painter, ScLayer& layer, QRect clip)
 	int docCurrPageNo=static_cast<int>(m_doc->currentPageNumber());
 	if ((layerCount > 1) && ((layer.blendMode != 0) || (layer.transparency != 1.0)) && (!layer.outlineMode))
 		painter->beginLayer(layer.transparency, layer.blendMode);
+
+	//if notes are used
+	//then we must be shure that text frames are valid and all notes frames are created before we start drawing
+	if (!notesFramesPass && !m_doc->m_docNotesList.isEmpty())
+	{
+		for (int it = 0; it < m_doc->Items->count(); ++it)
+		{
+			currItem = m_doc->Items->at(it);
+			if ( !currItem->isTextFrame()
+				|| currItem->isNoteFrame()
+				|| !currItem->invalid
+				|| (currItem->LayerID != layer.ID)
+				|| (m_viewMode.previewMode && !currItem->printEnabled())
+				|| (m_viewMode.viewAsPreview && (!currItem->printEnabled()))
+				|| (m_doc->masterPageMode() && ((currItem->OwnPage != -1) && (currItem->OwnPage != docCurrPageNo)))
+				|| ((!m_doc->masterPageMode() && !currItem->OnMasterPage.isEmpty()) && (currItem->OnMasterPage != m_doc->currentPage()->pageName())))
+				continue;
+			if (cullingArea.intersects(currItem->getBoundingRect().adjusted(0.0, 0.0, 1.0, 1.0)))
+				currItem->layout();
+		}
+	}
 	for (int it = 0; it < m_doc->Items->count(); ++it)
 	{
 		currItem = m_doc->Items->at(it);
+		if (notesFramesPass && !currItem->isNoteFrame())
+			continue;
+		if (!notesFramesPass && currItem->isNoteFrame())
+			continue;
 		if (currItem->LayerID != layer.ID)
 			continue;
 		if ((m_viewMode.previewMode) && (!currItem->printEnabled()))
diff --git a/Scribus/scribus/canvas.h b/Scribus/scribus/canvas.h
index ab4367b..d7e2a96 100644
--- a/Scribus/scribus/canvas.h
+++ b/Scribus/scribus/canvas.h
@@ -194,7 +194,8 @@ public:
 	void setPreviewVisual(int mode);
 	
 	void DrawMasterItems(ScPainter *painter, ScPage *page, ScLayer& layer, QRect clip);
-	void DrawPageItems(ScPainter *painter, ScLayer& layer, QRect clip);
+	//notesFramesPass determine if notes frames are drawed or not
+	void DrawPageItems(ScPainter *painter, ScLayer& layer, QRect clip, bool notesFramesPass);
 	virtual void paintEvent ( QPaintEvent * p );
 	void displayXYHUD(QPoint m);
 	void displayCorrectedXYHUD(QPoint m, double x, double y);
diff --git a/Scribus/scribus/canvasmode_edit.cpp b/Scribus/scribus/canvasmode_edit.cpp
index 97098cd..70d53fa 100644
--- a/Scribus/scribus/canvasmode_edit.cpp
+++ b/Scribus/scribus/canvasmode_edit.cpp
@@ -315,10 +315,15 @@ void CanvasMode_Edit::mouseDoubleClickEvent(QMouseEvent *m)
 				currItem->itemText.extendSelection(start, stop);
 				currItem->itemText.setCursorPosition(stop);
 			}
+			else if ((currItem->itemText.cursorPosition() < currItem->itemText.length()) && (currItem->itemText.item(currItem->itemText.cursorPosition())->mark != NULL))
+			{	//invoke edit marker dialog
+				m_ScMW->slotEditMark();
+				return;
+			}
 			else
 			{	//Double click in a frame to select a word
 				oldCp = currItem->itemText.cursorPosition();
-				if (currItem->itemText.hasObject(oldCp))
+				if ((oldCp < currItem->itemText.length()) && currItem->itemText.hasObject(oldCp))
 				{
 					currItem->itemText.select(oldCp, 1, true);
 					PageItem *iItem = currItem->itemText.object(oldCp);
diff --git a/Scribus/scribus/canvasmode_normal.cpp b/Scribus/scribus/canvasmode_normal.cpp
index ee0ce5c..3473642 100644
--- a/Scribus/scribus/canvasmode_normal.cpp
+++ b/Scribus/scribus/canvasmode_normal.cpp
@@ -243,6 +243,9 @@ void CanvasMode_Normal::mouseDoubleClickEvent(QMouseEvent *m)
 			{
 				m_view->requestMode(modeEdit);
 				m_view->slotSetCurs(m->globalPos().x(), m->globalPos().y());
+				//used for updating Notessets Manager and menu actions for marks
+				//if cursor is in mark`s place
+				m_ScMW->setTBvals(currItem);
 				//CB ignore the double click and go with a single one
 				//if we werent in mode edit before.
 				//unsure if this is correct, but its ok given we had no
diff --git a/Scribus/scribus/documentchecker.cpp b/Scribus/scribus/documentchecker.cpp
index 46b813a..9dd99ff 100644
--- a/Scribus/scribus/documentchecker.cpp
+++ b/Scribus/scribus/documentchecker.cpp
@@ -74,30 +74,36 @@ bool DocumentChecker::checkDocument(ScribusDoc *currDoc)
 	currDoc->masterItemErrors.clear();
 	currDoc->docLayerErrors.clear();
 	errorCodes itemError;
-	errorCodes layerError;
-	int Lnr;
-	ScLayer ll;
-	ll.ID = 0;
-	Lnr = 0;
-	uint layerCount= currDoc->layerCount();
-	for (uint la = 0; la < layerCount; ++la)
 	{
-		layerError.clear();
-		currDoc->Layers.levelToLayer(ll, Lnr);
-		if ((ll.isViewable != ll.isPrintable) && (checkerSettings.checkOffConflictLayers))
-			layerError.insert(OffConflictLayers, 0);
-		if ((!ll.isViewable) && (checkerSettings.ignoreOffLayers))
-			continue;
-		if ((!ll.isPrintable) && (checkerSettings.ignoreOffLayers))
-			continue;
-		if ((ll.transparency != 1.0) && (checkerSettings.checkTransparency))
-			layerError.insert(Transparency, 0);
-		if ((ll.blendMode != 0) && (checkerSettings.checkTransparency))
-			layerError.insert(BlendMode, 1);
-		Lnr++;
-		if (layerError.count() != 0)
-			currDoc->docLayerErrors.insert(ll.ID, layerError);
+		errorCodes layerError;
+		int Lnr;
+		ScLayer ll;
+		ll.ID = 0;
+		Lnr = 0;
+		uint layerCount= currDoc->layerCount();
+		for (uint la = 0; la < layerCount; ++la)
+		{
+			layerError.clear();
+			currDoc->Layers.levelToLayer(ll, Lnr);
+			if ((ll.isViewable != ll.isPrintable) && (checkerSettings.checkOffConflictLayers))
+				layerError.insert(OffConflictLayers, 0);
+			if ((!ll.isViewable) && (checkerSettings.ignoreOffLayers))
+				continue;
+			if ((!ll.isPrintable) && (checkerSettings.ignoreOffLayers))
+				continue;
+			if ((ll.transparency != 1.0) && (checkerSettings.checkTransparency))
+				layerError.insert(Transparency, 0);
+			if ((ll.blendMode != 0) && (checkerSettings.checkTransparency))
+				layerError.insert(BlendMode, 1);
+			Lnr++;
+			if (layerError.count() != 0)
+				currDoc->docLayerErrors.insert(ll.ID, layerError);
+		}
 	}
+
+	//update all marks references and check if that changes anything in doc
+	currDoc->flag_notesChanged = currDoc->updateMarks(true);
+
 	QList<PageItem*> allItems;
 	uint masterItemsCount = currDoc->MasterItems.count();
 	for (uint i = 0; i < masterItemsCount; ++i)
diff --git a/Scribus/scribus/marks.h b/Scribus/scribus/marks.h
new file mode 100644
index 0000000..b8dc452
--- /dev/null
+++ b/Scribus/scribus/marks.h
@@ -0,0 +1,94 @@
+#ifndef MARKS_H
+#define MARKS_H
+
+#include "QString"
+#include "scribusapi.h"
+#include "desaxe/saxiohelper.h"
+#include "desaxe/simple_actions.h"
+
+class Mark;
+class PageItem;
+class TextNote;
+
+enum MarkType
+{
+	MARKNoType = -1, //undefinied mark type (wrong situation!)
+	MARKAnchorType = 0, //empty anchor mark, useful for creating references to it
+	MARK2ItemType = 1, //reference to page item ID
+	MARK2MarkType = 2, //reference other mark
+	MARKVariableTextType = 3,//mark contain dynamic text
+	MARKNoteMasterType = 4,  //mark contain footnote reference
+	MARKNoteFrameType = 5,  //mark used internally in note frame at beginning of note`s text
+	MARKIndexType = 6 // index entry
+};
+
+struct MarkData
+{
+	QString strtxt;
+	PageItem* itemPtr;
+	QString destmarkName;
+	MarkType destmarkType;
+	TextNote* notePtr;
+	//fields used for resolving to pointers for load and copy
+	QString itemName;
+	MarkType markTyp;
+	
+	MarkData() : strtxt(""), itemPtr(NULL), destmarkName(""), destmarkType(MARKNoType), notePtr(NULL), itemName(""), markTyp(MARKNoType) {}
+};
+
+class SCRIBUS_API Mark
+{
+public:
+	Mark() : label(""), OwnPage(-1), typ(MARKNoType), data() {}
+	Mark(const Mark& other) : label(other.label), OwnPage(other.OwnPage), typ(other.typ), data(other.data) {}
+	~Mark() {}
+
+	QString label;
+	int OwnPage;
+
+	void setValues(QString l, int p, MarkType t, MarkData d) { label = l; OwnPage = p; typ = t; data = d; }
+	const MarkType getType() { return typ; }
+	void setType(MarkType t) { typ = t; }
+	const MarkData getData() { return data; }
+	void setData(const MarkData d) { data = d; }
+	PageItem* getItemPtr() { return data.itemPtr; }
+	void setItemPtr( PageItem* ptr ) { data.itemPtr = ptr; }
+	const QString getItemName() { return data.itemName; }
+	void setItemName( const QString name ) { data.itemName = name; }
+
+	//for marks to marks - return label and type of target mark by reference
+	const void getMark(QString &l, MarkType &t) { l = data.destmarkName; t = data.destmarkType; }
+	//for marks to marks - set label and type of target mark from mark pointer
+	void setMark(Mark* mP)
+	{
+		if (mP == NULL)
+		{
+			data.destmarkName = "";
+			data.destmarkType = MARKNoType;
+		}
+		else
+		{
+			data.destmarkName = mP->label;
+			data.destmarkType = mP->getType();
+		}
+	}
+	const MarkType getMarkType() { return data.markTyp; }
+	void setMarkType(MarkType t) { data.markTyp = t; }
+	const QString getString() { return data.strtxt; }
+	void setString( const QString str ) { data.strtxt = str; }
+	TextNote* getNotePtr() { return data.notePtr; }
+	void setNotePtr(TextNote *note) { data.notePtr = note; }
+
+	bool hasItemPtr() { return data.itemPtr != NULL; }
+	bool hasString() { return !data.strtxt.isEmpty(); }
+	bool hasMark() { return data.destmarkName != ""; }
+	bool isUnique() { return ((typ != MARKVariableTextType) && (typ != MARKIndexType)); }
+	bool isNoteType() { return ((typ == MARKNoteMasterType) || (typ==MARKNoteFrameType)); }
+	bool isType(const MarkType t) { return t==typ; }
+
+private:
+	MarkType typ;
+	MarkData data;
+};
+
+#endif // MARKS_H
diff --git a/Scribus/scribus/notesset.cpp b/Scribus/scribus/notesset.cpp
new file mode 100644
index 0000000..485937c
--- /dev/null
+++ b/Scribus/scribus/notesset.cpp
@@ -0,0 +1,64 @@
+#include "notesset.h"
+#include "marks.h"
+
+NotesSet::NotesSet()
+{
+	//TODO read values from doc prefs
+	nameStr = "default";
+	m_endNotesSet = false;
+	numeration.setType(Type_1_2_3);
+	startNum = 1;
+	numRange = NSRdocument;
+	prefixStr = "";
+	suffixStr = ")";
+	autoNotesHeight = true;
+	autoNotesWidth = true;
+	autoRemoveEmptyNotesFrames = true;
+	autoWeldNotesFrames = true;
+	superscriptInNote = true;
+	superscriptInMaster = true;
+	marksCharStyle = "";
+	notesStyle = "";
+}
+
+NotesSet::~NotesSet()
+{
+	
+}
+
+void NotesSet::deleteAll()
+{
+	//nList->clear();
+}
+
+void NotesSet::setEndNotes(bool setendnotes)
+{
+	if (m_endNotesSet != setendnotes)
+	{
+		m_endNotesSet = setendnotes;
+	}
+}
+
+bool NotesSet::operator!=(const NotesSet& n2)
+{
+	return ((nameStr != n2.nameStr) || (startNum != n2.startNum) || (m_endNotesSet != n2.m_endNotesSet) ||
+			(getType() != static_cast<NotesSet>(n2).getType()) || (numRange != n2.numRange) ||
+			(prefixStr != n2.prefixStr) || (suffixStr != n2.suffixStr) ||
+			(autoNotesHeight != n2.autoNotesHeight) || (autoNotesWidth != n2.autoNotesWidth) ||
+			(autoRemoveEmptyNotesFrames != n2.autoRemoveEmptyNotesFrames) || (autoWeldNotesFrames != n2.autoWeldNotesFrames) ||
+			(superscriptInMaster != n2.superscriptInMaster) || (superscriptInNote != n2.superscriptInNote) ||
+			(marksCharStyle != n2.marksCharStyle) || (notesStyle != n2.notesStyle)
+			);
+}
+
+TextNote::~TextNote()
+{
+	if (masterMark() != NULL)
+	{
+		masterMark()->setNotePtr(NULL);
+	}
+	if (noteMark() != NULL)
+	{
+		noteMark()->setNotePtr(NULL);
+	}
+}
diff --git a/Scribus/scribus/notesset.h b/Scribus/scribus/notesset.h
new file mode 100644
index 0000000..b1056cc
--- /dev/null
+++ b/Scribus/scribus/notesset.h
@@ -0,0 +1,139 @@
+#ifndef NOTESSET_H
+#define NOTESSET_H
+
+#include <QDebug>
+#include <QObject>
+#include <QString>
+#include <QList>
+#include "pagestructs.h"
+#include "scpage.h"
+#include "styles/charstyle.h"
+#include "styles/paragraphstyle.h"
+#include "text/storytext.h"
+#include "util.h"
+
+class ScribusDoc;
+class PageItem_NoteFrame;
+class PageItem_TextFrame;
+
+class Numeration
+{
+public:
+	Numeration() : numType(Type_1_2_3) {}
+	void setType(NumerationType type) { numType = type; }
+	const NumerationType type() { return numType; }
+	const QString numString(const int num) { return getStringFromSequence(numType, num); }
+private:
+	NumerationType numType;
+};
+
+typedef enum {
+	NSRdocument,
+	NSRsection,
+	NSRstory,
+	NSRpage,
+	NSRframe
+} NumerationRange;
+
+//used for map with endnotes frames maped with range item
+typedef union
+{
+	void* P;
+	int sectionIndex;
+	ScPage* page;
+	PageItem_TextFrame* firstStoryFrame;
+} rangeItem;
+
+class SCRIBUS_API NotesSet
+{
+public:
+	//NotesSet(QString nameStr, NumerationType numType, int start, NumerationRange limit, void *itemPtr, bool setendnote = false);
+	NotesSet();
+	//NotesSet& operator=(const NotesSet& other);
+	~NotesSet();
+	bool operator!=(const NotesSet& n2);
+
+	const QString name() { return nameStr; }
+	void setName(const QString s) { nameStr = s; }
+	const int start() { return startNum; }
+	void setStart(const int i) { startNum = i; }
+	void setRange(NumerationRange ns) { numRange = ns; }
+	const NumerationRange range() { return numRange; }
+	const QString prefix() { return prefixStr; }
+	void setPrefix (const QString str) { prefixStr = str; }
+	const QString suffix() { return suffixStr; }
+	void setSuffix (const QString str) { suffixStr = str; }
+
+	const QString numString(const int num) { return numeration.numString(num); }
+	void setType(const NumerationType type) { numeration.setType(type); }
+	const NumerationType getType() { return numeration.type(); }
+
+	bool isEndNotes() { return m_endNotesSet; }
+	bool isAutoNotesHeight() { return autoNotesHeight; }
+	void setAutoNotesHeight(const bool set) { autoNotesHeight = set; }
+	bool isAutoNotesWidth() { return autoNotesWidth; }
+	void setAutoNotesWidth(const bool set) { autoNotesWidth = set; }
+	bool isAutoRemoveEmptyNotesFrames() { return autoRemoveEmptyNotesFrames; }
+	void setAutoRemoveEmptyNotesFrames(const bool set) { autoRemoveEmptyNotesFrames = set; }
+	bool isAutoWeldNotesFrames() { return autoWeldNotesFrames; }
+	void setAutoWeldNotesFrames(const bool set) { autoWeldNotesFrames = set; }
+	bool isSuperscriptInNote() { return superscriptInNote; }
+	void setSuperscriptInNote(const bool set) { superscriptInNote = set; }
+	bool isSuperscriptInMaster() { return superscriptInMaster; }
+	void setSuperscriptInMaster(const bool set) { superscriptInMaster = set; }
+	const QString marksChStyle() { return marksCharStyle; }
+	void setMarksCharStyle(const QString styleName) { marksCharStyle = styleName; }
+	const QString notesParStyle() { return notesStyle; }
+	void setNotesParStyle(const QString styleName) { notesStyle = styleName; }
+	
+	void deleteAll();
+	void setEndNotes(bool);
+
+private:
+	QString nameStr;		//unique name of notes set
+	int startNum;			//numeration starts with that number
+
+	bool m_endNotesSet;		//if not true this is set of footnotes
+	Numeration numeration;
+	NumerationRange numRange;	//range of numeration for current set
+	QString prefixStr;
+	QString suffixStr;
+	bool autoNotesHeight;				//change height of notes frames to its content automaticaly?
+	bool autoNotesWidth;				//change width of notes frames automaticaly if width of master frame changes?
+	bool autoRemoveEmptyNotesFrames;
+	bool autoWeldNotesFrames;
+	bool superscriptInNote;
+	bool superscriptInMaster;
+	QString marksCharStyle;
+	QString notesStyle;
+};
+
+class SCRIBUS_API TextNote : public QObject
+{
+    Q_OBJECT
+public:
+	TextNote(NotesSet *nSet) : notesset(nSet), noteSaxedText(""), noteMasterMark(NULL), noteFrameMark(NULL), number(0) { }
+	~TextNote();
+
+	void setNotesSet (NotesSet* NS) { notesset = NS; }
+	NotesSet* notesSet() { return notesset; }
+	const int num() { return number; }
+	void setNum(const int x) { number = x; }
+	const QString numString() { return notesSet()->numString(number); }
+	Mark* masterMark() { return noteMasterMark; }
+	void setMasterMark(Mark* MRK) { noteMasterMark = MRK; }
+	Mark* noteMark() { return noteFrameMark; }
+	void setNoteMark(Mark* MRK) { noteFrameMark = MRK; }
+	const QString saxedText() { return noteSaxedText; }
+	void setSaxedText(const QString string) { noteSaxedText = string; }
+	bool isEndNote() { return notesset->isEndNotes(); }
+
+private:
+	NotesSet *notesset;
+	QString noteSaxedText;
+	Mark *noteMasterMark;
+	Mark *noteFrameMark;
+	int number;
+};
+
+#endif // NOTESSET_H
diff --git a/Scribus/scribus/pageitem.cpp b/Scribus/scribus/pageitem.cpp
index 19c0c2c..2055381 100644
--- a/Scribus/scribus/pageitem.cpp
+++ b/Scribus/scribus/pageitem.cpp
@@ -35,18 +35,20 @@ for which a new license (GPL+exception) is in place.
 #include <QMessageBox>
 #include <QPolygon>
 #include <cassert>
+#include <sstream>
 #include <QDebug>
 
 #include "canvas.h"
 #include "cmsettings.h"
 #include "colorblind.h"
 #include "commonstrings.h"
-
+#include "desaxe/saxXML.h"
+#include "marks.h"
 #include "pageitem_group.h"
 #include "pageitem_textframe.h"
+#include "pageitem_noteframe.h"
 #include "pageitem_latexframe.h"
 #include "prefsmanager.h"
-
 #include "resourcecollection.h"
 #include "scclocale.h"
 #include "sccolorengine.h"
@@ -825,6 +827,32 @@ PageItem::PageItem(ScribusDoc *pa, ItemType newType, double x, double y, double
 	isInlineImage = false;
 }
 
+PageItem::~PageItem()
+{
+	if (tempImageFile != NULL)
+		delete tempImageFile;
+	//remove marks
+
+	if (isTextFrame())
+	{
+		if (!asTextFrame()->isInChain() && itemText.length() >0)
+		{
+			for (int pos=0; pos < itemText.length(); ++pos)
+			{
+				if (itemText.item(pos)->hasMark())
+				{
+					Mark* mrk = itemText.item(pos)->mark;
+					m_Doc->eraseMark(mrk);
+				}
+			}
+		}
+	}
+//		if (isWeld())
+//			unWeldFromMaster(true);
+//		if (isWelded())
+//			unWeldChild();
+}
+
 void PageItem::setXPos(const double newXPos, bool drawingOnly)
 {
 	Xpos = newXPos;
@@ -2139,6 +2167,15 @@ QString PageItem::ExpandToken(uint base)
 		else
 			return "%";
 	}
+	//check for marks
+	else if (ch == SpecialChars::OBJECT)
+	{
+		ScText* hl = itemText.item(base);
+		if ((hl->mark != NULL) && !hl->mark->isType(MARKAnchorType) && !hl->mark->isType(MARKIndexType))
+		{
+			chstr = hl->mark->getString();
+		}
+	}
 	return chstr;
 }
 
@@ -2322,6 +2359,13 @@ void PageItem::drawGlyphs(ScPainter *p, const CharStyle& style, GlyphLayout& gly
 			points.addQuadPoint(0, -10, 0, -10, 0, -6, 0, -6);
 			stroke = true;
 		}
+		else if (glyph == SpecialChars::OBJECT.unicode())
+		{
+			//for marks as control chars
+			points.resize(0);
+			points.addQuadPoint(0, -8, 1, -8, 0, -6, 1, -6);
+			stroke = true;
+		}
 		else // ???
 		{
 			points.resize(0);
@@ -5104,7 +5148,8 @@ void PageItem::setObjectAttributes(ObjAttrVector* map)
 	pageItemAttributes=*map;
 }
 
-QString PageItem::generateUniqueCopyName(const QString originalName) const
+//if not `prependCopy` then string "Copy of" wil not be prepended
+QString PageItem::generateUniqueCopyName(const QString originalName, bool prependCopy) const
 {
 	if (!m_Doc->itemNameExists(originalName))
 		return originalName;
@@ -5112,7 +5157,7 @@ QString PageItem::generateUniqueCopyName(const QString originalName) const
 	// Start embellishing the name until we get an acceptable unique name
 	// first we prefix `Copy of' if it's not already there
 	QString newname(originalName);
-	if (!originalName.startsWith( tr("Copy of")))
+	if (prependCopy && !originalName.startsWith( tr("Copy of")))
 		newname.prepend( tr("Copy of")+" ");
 
 	// See if the name prefixed by "Copy of " is free
@@ -6728,6 +6773,24 @@ void PageItem::setFileIconRollover(QString val)
 	}
 }
 
+PageItem* PageItem::firstInChain()
+{
+	Q_ASSERT(this != NULL);
+	PageItem* first = this;
+	while (first->prevInChain() != NULL)
+		first = first->prevInChain();
+	return first;
+}
+
+PageItem* PageItem::lastInChain()
+{
+	Q_ASSERT(this != NULL);
+	PageItem* last = this;
+	while (last->nextInChain() != NULL)
+		last = last->nextInChain();
+	return last;
+}
+
 QRect PageItem::getRedrawBounding(const double viewScale)
 {
 	int x = qRound(floor(BoundingX - Oldm_lineWidth / 2.0 - 5) * viewScale);
@@ -7032,7 +7095,8 @@ void PageItem::convertClip()
 	}
 }
 
-void PageItem::updateClip()
+//udateWelded determine if welded items should be updated as well (default behaviour)
+void PageItem::updateClip(bool updateWelded)
 {
 	if (m_Doc->appMode == modeDrawBezierLine)
 		return;
@@ -7142,18 +7206,40 @@ void PageItem::updateClip()
 					else
 						Clip = FlattenPath(PoLine, Segments);
 				}
-				for (int i = 0 ; i < weldList.count(); i++)
+				if (updateWelded)
 				{
-					weldingInfo wInf = weldList.at(i);
-					FPointArray gr4;
-					FPoint wp = wInf.weldPoint;
-					gr4.addPoint(wp);
-					gr4.map(ma);
-					double dx = gr4.point(0).x() - wp.x();
-					double dy = gr4.point(0).y() - wp.y();
-					moveWelded(dx, dy, i);
-					wInf.weldPoint = gr4.point(0);
-					weldList[i] = wInf;
+					for (int i = 0 ; i < weldList.count(); i++)
+					{
+						weldingInfo wInf = weldList.at(i);
+						if (wInf.weldItem->isNoteFrame())
+						{
+							PageItem_NoteFrame* noteFrame = wInf.weldItem->asNoteFrame();
+							if (noteFrame->notesSet()->isAutoWeldNotesFrames())
+							{
+								if (noteFrame->notesSet()->isAutoNotesWidth())
+								{
+									if (noteFrame->width() != width())
+									{
+										noteFrame->setWidth(width());
+										noteFrame->updateClip();
+									}
+								}
+								noteFrame->setXYPos(xPos(),yPos() + height());
+								setWeldPoint(0, height(), noteFrame);
+								noteFrame->setWeldPoint(0,0, this);
+								continue;
+							}
+						}
+						FPointArray gr4;
+						FPoint wp = wInf.weldPoint;
+						gr4.addPoint(wp);
+						gr4.map(ma);
+						double dx = gr4.point(0).x() - wp.x();
+						double dy = gr4.point(0).y() - wp.y();
+						moveWelded(dx, dy, i);
+						wInf.weldPoint = gr4.point(0);
+						weldList[i] = wInf;
+					}
 				}
 			}
 			OldB2 = width();
@@ -7255,18 +7341,39 @@ void PageItem::updateClip()
 				Clip = FlattenPath(PoLine, Segments);
 			OldB2 = width();
 			OldH2 = height();
-			for (int i = 0 ; i < weldList.count(); i++)
+			if (updateWelded)
 			{
-				weldingInfo wInf = weldList.at(i);
-				FPointArray gr4;
-				FPoint wp = wInf.weldPoint;
-				gr4.addPoint(wp);
-				gr4.map(ma);
-				double dx = gr4.point(0).x() - wp.x();
-				double dy = gr4.point(0).y() - wp.y();
-				moveWelded(dx, dy, i);
-				wInf.weldPoint = gr4.point(0);
-				weldList[i] = wInf;
+				for (int i = 0 ; i < weldList.count(); i++)
+				{
+					weldingInfo wInf = weldList.at(i);
+					if (wInf.weldItem->isNoteFrame())
+					{
+						PageItem_NoteFrame* noteFrame = wInf.weldItem->asNoteFrame();
+						if (noteFrame->notesSet()->isAutoWeldNotesFrames())
+						{
+							if (noteFrame->notesSet()->isAutoNotesWidth())
+							{
+								if (noteFrame->width() != width())
+								{
+									noteFrame->setWidth(width());
+									noteFrame->updateClip();
+								}
+							}
+							setWeldPoint(0, height(), noteFrame);
+							noteFrame->setWeldPoint(0,0, this);
+							continue;
+						}
+					}
+					FPointArray gr4;
+					FPoint wp = wInf.weldPoint;
+					gr4.addPoint(wp);
+					gr4.map(ma);
+					double dx = gr4.point(0).x() - wp.x();
+					double dy = gr4.point(0).y() - wp.y();
+					moveWelded(dx, dy, i);
+					wInf.weldPoint = gr4.point(0);
+					weldList[i] = wInf;
+				}
 			}
 		}
 		break;
@@ -7376,6 +7483,8 @@ void PageItem::weldTo(PageItem* pIt)
 
 void PageItem::moveWelded(double DX, double DY, int weld)
 {
+	if ((DX == 0) && (DY == 0))
+		return;
 	weldingInfo wInf = weldList.at(weld);
 	PageItem *pIt = wInf.weldItem;
 	pIt->setXPos(pIt->xPos() + DX);
@@ -7386,6 +7495,8 @@ void PageItem::moveWelded(double DX, double DY, int weld)
 
 void PageItem::moveWelded(double DX, double DY, PageItem* except)
 {
+	if ((DX == 0) && (DY == 0))
+		return;
 	for (int i = 0 ; i < weldList.count(); i++)
 	{
 		weldingInfo wInf = weldList.at(i);
@@ -7394,7 +7505,8 @@ void PageItem::moveWelded(double DX, double DY, PageItem* except)
 		{
 			pIt->setXPos(pIt->xPos() + DX);
 			pIt->setYPos(pIt->yPos() + DY);
-			pIt->update();
+			if (!pIt->isNoteFrame())
+				pIt->update();
 			pIt->moveWelded(DX, DY, this);
 		}
 	}
@@ -7451,6 +7563,19 @@ QList<PageItem*> PageItem::itemsWeldedTo(PageItem* except)
 	return ret;
 }
 
+void PageItem::setWeldPoint(double DX, double DY, PageItem *pItem)
+{
+	for (int i = 0 ; i < weldList.count(); i++)
+	{
+		PageItem *pIt = weldList[i].weldItem;
+		if (pIt == pItem)
+		{
+			weldList[i].weldPoint = FPoint(DX, DY);
+			return;
+		}
+	}
+}
+
 void PageItem::unWeld()
 {
 	for (int a = 0 ; a < weldList.count(); a++)
@@ -7471,3 +7596,26 @@ void PageItem::unWeld()
 	weldList.clear();
 }
 
+QString PageItem::getItemTextSaxed(int selStart, int selLength)
+{
+	if (selStart < 0 || selLength < 0)
+		return QString();
+	
+	StoryText it(m_Doc);
+	it.setDefaultStyle(itemText.defaultStyle());
+
+	if (selLength == 0)
+		selLength = 1;
+	itemText.select(selStart, selLength);
+	it.insert(0, itemText, true);
+	itemText.deselectAll();
+
+	//saxing text
+	std::ostringstream xmlString;
+	SaxXML xmlStream(xmlString);
+	xmlStream.beginDoc();
+	it.saxx(xmlStream, "SCRIBUSTEXT");
+	xmlStream.endDoc();
+	std::string xml(xmlString.str());
+	return QString(xml.c_str());
+}
diff --git a/Scribus/scribus/pageitem.h b/Scribus/scribus/pageitem.h
index c5a5861..b1f0831 100644
--- a/Scribus/scribus/pageitem.h
+++ b/Scribus/scribus/pageitem.h
@@ -40,6 +40,7 @@ for which a new license (GPL+exception) is in place.
 #include "annotation.h"
 #include "colormgmt/sccolormgmtstructs.h"
 #include "desaxe/saxio.h"
+//#include "notesset.h"
 #include "observable.h"
 #include "pagestructs.h"
 #include "scimage.h"
@@ -72,6 +73,7 @@ class PageItem_PolyLine;
 class PageItem_RegularPolygon;
 class PageItem_Table;
 class PageItem_TextFrame;
+class PageItem_NoteFrame;
 class PageItem_PathText;
 class PageItem_LatexFrame;
 class PageItem_Spiral;
@@ -99,6 +101,9 @@ class SCRIBUS_API PageItem : public QObject, public UndoObject, public SaxIO, pu
 	Q_PROPERTY(double lineTransparency READ lineTransparency WRITE setLineTransparency DESIGNABLE false)
 	Q_PROPERTY(bool m_Locked READ locked WRITE setLocked DESIGNABLE false)
 	Q_PROPERTY(bool m_SizeLocked READ sizeLocked WRITE setSizeLocked DESIGNABLE false)
+	//used for notes frames
+	Q_PROPERTY(bool m_SizeHLocked READ sizeHLocked WRITE setSizeHLocked DESIGNABLE false)
+	Q_PROPERTY(bool m_SizeVLocked READ sizeVLocked WRITE setSizeVLocked DESIGNABLE false)
 	Q_PROPERTY(bool m_ImageIsFlippedV READ imageFlippedV WRITE setImageFlippedV DESIGNABLE false)
 	Q_PROPERTY(bool m_ImageIsFlippedH READ imageFlippedH WRITE setImageFlippedH DESIGNABLE false)
 	Q_PROPERTY(double lineWidth READ lineWidth WRITE setLineWidth DESIGNABLE false)
@@ -195,6 +200,7 @@ public:
 	virtual PageItem_Polygon * asPolygon() { return NULL; }
 	virtual PageItem_PolyLine * asPolyLine() { return NULL; }
 	virtual PageItem_TextFrame * asTextFrame() { return NULL; }
+	virtual PageItem_NoteFrame * asNoteFrame() { return NULL; }
 	virtual PageItem_LatexFrame * asLatexFrame() { return NULL; }
 
 	virtual PageItem_OSGFrame * asOSGFrame() { return NULL; }
@@ -219,6 +225,7 @@ public:
 	virtual bool isArc()			const { return false; }
 	virtual bool isSpiral()			const { return false; }
 	virtual bool isTable()			const { return false; }
+	virtual bool isNoteFrame()		const { return false; }
 
 	/** @brief Frame Type
 	 *
@@ -237,15 +244,7 @@ protected:
 	
 public:
 	PageItem(ScribusDoc *pa, ItemType newType, double x, double y, double w, double h, double w2, QString fill, QString outline);
-	~PageItem()
-	{
-		if (tempImageFile != NULL)
-			delete tempImageFile;
-//		if (isWeld())
-//			unWeldFromMaster(true);
-//		if (isWelded())
-//			unWeldChild();
-	}
+	~PageItem();
 
 	// Get item level relative to its parent doc or group
 	int level();
@@ -322,7 +321,8 @@ public:
 	void SetFrameRound();
 	void setPolyClip(int up, int down = 0);
 	void updatePolyClip();
-	void updateClip();
+	//added switch for not updating welded items - used by notes frames with automatic size adjusted
+	void updateClip(bool updateWelded = true);
 	void convertClip();
 	void getBoundingRect(double *x1, double *y1, double *x2, double *y2) const;
 	void getVisualBoundingRect(double *x1, double *y1, double *x2, double *y2) const;
@@ -542,6 +542,9 @@ public:
 	PageItem* nextInChain() { return NextBox; }
 	const PageItem* prevInChain() const { return BackBox; }
 	const PageItem* nextInChain() const { return NextBox; }
+	//you can change all code for search first or last item in chain
+	PageItem* firstInChain();
+	PageItem* lastInChain();
 	PageItem *Parent;
 
 	bool testLinkCandidate(PageItem* nextFrame);
@@ -1014,8 +1017,12 @@ public:
 	void toggleSizeLock();
 	/** @brief Is the item's size locked? */
 	bool sizeLocked() const { return m_SizeLocked; }
+	bool sizeHLocked() const { return m_SizeHLocked || m_SizeLocked; }
+	bool sizeVLocked() const { return m_SizeVLocked || m_SizeLocked; }
 	/** @brief set lock for resizing */
 	void setSizeLocked(bool isLocked);
+	void setSizeHLocked(bool isLocked) { m_SizeHLocked = isLocked; }
+	void setSizeVLocked(bool isLocked) { m_SizeVLocked = isLocked; }
 
 	/**
 	 * @brief Does text flow around this object and how
@@ -1126,8 +1133,9 @@ public:
 	 * @author Craig Ringer
 	 *
 	 * Usually of the form 'Copy of [name]' or 'Copy of [name] (n)'
+	 * cezaryece: if prependCopy is false then form '[name] (n)' is generated
 	 */
-	QString generateUniqueCopyName(const QString originalName) const;
+	QString generateUniqueCopyName(const QString originalName, bool prependCopy = true) const;
 	/**
 	 * @brief Is this item printed?
 	 * @sa setPrintEnabled()
@@ -1377,6 +1385,11 @@ protected:
 	bool m_SizeLocked;
 
 	/**
+	 * @for notes frames - locking horizontal or vertical size
+	**/
+	bool m_SizeHLocked;
+	bool m_SizeVLocked;
+	/**
 	 * @brief Should text flow around the item
 	 * @sa PageItem::textFlowMode(), PateItem::setTextFlowMode()
 	 */
@@ -1591,6 +1604,11 @@ public:
 	void moveWelded(double DX, double DY, int weld);
 	void moveWelded(double DX, double DY, PageItem* except = NULL);
 	void rotateWelded(double dR, double oldRot);
+	//added for autowelding feature of notes frames
+	//setting welding point with given pItem to given coords
+	void setWeldPoint(double DX, double DY, PageItem *pItem);
+	//used by notes frames to get content of notes from itemText
+	QString getItemTextSaxed(int selStart, int selLength);
 };
 
 Q_DECLARE_METATYPE(PageItem*)
diff --git a/Scribus/scribus/pageitem_noteframe.cpp b/Scribus/scribus/pageitem_noteframe.cpp
new file mode 100644
index 0000000..561ffbb
--- /dev/null
+++ b/Scribus/scribus/pageitem_noteframe.cpp
@@ -0,0 +1,386 @@
+#include <QMessageBox>
+#include "pageitem_noteframe.h"
+#include "pageitem_textframe.h"
+#include "pageitem.h"
+#include "scribus.h"
+#include "scribusdoc.h"
+#include "ui/scmessagebox.h"
+#include "util_text.h"
+
+
+PageItem_NoteFrame::PageItem_NoteFrame(NotesSet *nSet, ScribusDoc *doc, double x, double y, double w, double h, double w2, QString fill, QString outline)
+    : PageItem_TextFrame(doc, x, y, w, h, w2, fill, outline)
+{
+	m_nset = nSet;
+	m_masterFrame = NULL;
+	itemText.clear();
+
+	AnName = generateUniqueCopyName(nSet->isEndNotes() ? tr("Endnote frame ") + m_nset->name() : tr("Footnote frame ") + m_nset->name(), false);
+	AutoName = false; //endnotes frame will saved with name, so it can be stpred and connected with noteset while reading SLA
+	
+	//set default style for note frame
+	ParagraphStyle newStyle;
+	if (nSet->notesParStyle().isEmpty() || (nSet->notesParStyle() == tr("No Style")))
+	{
+		if (nSet->isEndNotes())
+			//set default doc style
+			newStyle.setParent(m_Doc->paragraphStyles()[0].name());
+		else
+		{
+			newStyle.setParent(m_masterFrame->itemText.defaultStyle().parent());
+			newStyle.applyStyle(m_masterFrame->currentStyle());
+		}
+	}
+	else
+		newStyle.setParent(nSet->notesParStyle());
+	itemText.blockSignals(true);
+	itemText.setDefaultStyle(newStyle);
+	itemText.blockSignals(false);
+
+	textFlowModeVal = TextFlowUsesFrameShape;
+	setColumns(1);
+
+	if (m_nset->isAutoNotesHeight())
+		m_SizeHLocked = true;
+	else
+		m_SizeLocked = false;
+	if (m_nset->isAutoNotesWidth())
+		m_SizeVLocked = true;
+	else
+		m_SizeVLocked = false;
+	if (m_nset->isAutoNotesHeight() && m_nset->isAutoNotesWidth())
+		m_SizeLocked = true;
+	else
+		m_SizeLocked = false;
+	deleteIt = false;
+	l_notes.empty();
+}
+
+PageItem_NoteFrame::PageItem_NoteFrame(ScribusDoc *doc, double x, double y, double w, double h, double w2, QString fill, QString outline)
+    : PageItem_TextFrame(doc, x, y, w, h, w2, fill, outline)
+{
+	m_nset = NULL;
+	m_masterFrame = NULL;
+	textFlowModeVal = TextFlowUsesFrameShape;
+	deleteIt = false;
+	l_notes.empty();
+}
+
+PageItem_NoteFrame::PageItem_NoteFrame(PageItem_TextFrame* inFrame, NotesSet *nSet) : PageItem_TextFrame(inFrame->doc(),inFrame->xPos(), inFrame->yPos(),inFrame->width(), inFrame->height(),inFrame->lineWidth(), inFrame->fillColor(), inFrame->lineColor())
+{
+	m_nset = nSet;
+	m_masterFrame = inFrame;
+
+	AnName = generateUniqueCopyName(nSet->isEndNotes() ? tr("Endnote frame ") + m_nset->name() : tr("Footnote frame ") + m_nset->name(), false);
+	AutoName = false;
+
+	//set default style for note frame
+	ParagraphStyle newStyle;
+	if (nSet->notesParStyle().isEmpty() || (nSet->notesParStyle() == tr("No Style")))
+	{
+		if (nSet->isEndNotes())
+			//set default doc style
+			newStyle.setParent(m_Doc->paragraphStyles()[0].name());
+		else
+		{
+			newStyle.setParent(m_masterFrame->itemText.defaultStyle().parent());
+			newStyle.applyStyle(m_masterFrame->currentStyle());
+		}
+	}
+	else
+		newStyle.setParent(nSet->notesParStyle());
+	itemText.blockSignals(true);
+	itemText.setDefaultStyle(newStyle);
+	itemText.blockSignals(false);
+	
+	double frameHeight = calculateLineSpacing(newStyle, this);
+	Height = frameHeight;
+	Ypos = m_masterFrame->yPos() + m_masterFrame->height();
+	textFlowModeVal = TextFlowUsesFrameShape;
+	setColumns(1);
+
+	if (m_nset->isAutoWeldNotesFrames() && (m_masterFrame != NULL))
+	{
+		addWelded(m_masterFrame);
+		m_masterFrame->addWelded(this);
+		m_masterFrame->setWeldPoint(0, m_masterFrame->height(), this);
+		setWeldPoint(0,0, m_masterFrame);
+	}
+	if (m_nset->isAutoNotesHeight())
+		m_SizeHLocked = true;
+	else
+		m_SizeLocked = false;
+	if (m_nset->isAutoNotesWidth())
+		m_SizeVLocked = true;
+	else
+		m_SizeVLocked = false;
+	if (m_nset->isAutoNotesHeight() && m_nset->isAutoNotesWidth())
+		m_SizeLocked = true;
+	else
+		m_SizeLocked = false;
+	deleteIt = false;
+	l_notes.empty();
+}
+
+void PageItem_NoteFrame::setNS(NotesSet *nSet, PageItem_TextFrame* master)
+{
+	m_nset = nSet;
+	if (master != NULL)
+		m_masterFrame = master;
+	itemText.clear();
+
+	AnName = generateUniqueCopyName(m_nset->isEndNotes() ? "Endnote frame " + m_nset->name() : "Footnote frame " + m_nset->name(), false);
+	
+	//set default style for note frame
+	ParagraphStyle newStyle;
+	if (nSet->notesParStyle().isEmpty() || (nSet->notesParStyle() == tr("No Style")))
+	{
+		if (nSet->isEndNotes() || (m_masterFrame == NULL))
+		{
+			//set default doc style
+			newStyle.setParent(m_Doc->paragraphStyles()[0].name());
+		}
+		else if (master != NULL)
+		{
+			newStyle.setParent(m_masterFrame->itemText.defaultStyle().parent());
+			newStyle.applyStyle(m_masterFrame->currentStyle());
+		}
+	}
+	else
+		newStyle.setParent(nSet->notesParStyle());
+	itemText.blockSignals(true);
+	itemText.setDefaultStyle(newStyle);
+	itemText.blockSignals(false);
+
+	if (m_nset->isAutoNotesHeight())
+		m_SizeHLocked = true;
+	else
+		m_SizeLocked = false;
+	if (m_nset->isAutoNotesWidth())
+		m_SizeVLocked = true;
+	else
+		m_SizeVLocked = false;
+	if (m_nset->isAutoNotesHeight() && m_nset->isAutoNotesWidth())
+		m_SizeLocked = true;
+	else
+		m_SizeLocked = false;
+}
+
+void PageItem_NoteFrame::layout()
+{
+	if (!invalid || deleteIt)
+		return;
+	if (!m_Doc->flag_layoutNotesFrames || m_Doc->isLoading())
+		return;
+	if (itemText.length() == 0)
+		return;
+	if ((masterFrame() != NULL) && masterFrame()->invalid)
+		masterFrame()->layout();
+
+	if (m_nset->isAutoNotesWidth() && (Width != m_masterFrame->width()))
+	{
+		Width = m_masterFrame->width();
+		updateClip();
+	}
+
+	if ((m_Doc->appMode == modeEdit) && isSelected())
+		updateNotesText();
+
+	PageItem_TextFrame::layout();
+	if (notesSet()->isAutoNotesHeight())
+	{
+		if (frameOverflows())
+		{
+			//increase height while text don`t fit in frame
+			double maxH = m_Doc->currentPage()->height() - Xpos;
+			while (frameOverflows())
+			{
+				Height += 8;
+				updateClip(false);
+				invalid = true;
+				PageItem_TextFrame::layout();
+				if (Height >= maxH)
+					break;
+			}
+		}
+		while ((!frameOverflows()))
+		{
+			--Height;
+			updateClip(false);
+			invalid = true;
+			PageItem_TextFrame::layout();
+		}
+		++Height;
+		updateClip();
+		invalid = true;
+		PageItem_TextFrame::layout();
+	}
+	m_Doc->regionsChanged()->update(getBoundingRect());
+	invalid = false;
+}
+
+void PageItem_NoteFrame::insertNote(TextNote *note, int index)
+{
+	if (index < 0) return;
+	Mark* mrk = note->noteMark();
+	if (mrk == NULL)
+	{
+		mrk = new Mark();
+		mrk->setType(MARKNoteFrameType);
+		QString label = "NoteFrameMark_" + notesSet()->name();
+		if (notesSet()->range() == NSRsection)
+			label += " in section " + m_Doc->getSectionNameForPageIndex(note->masterMark()->OwnPage) + " page " + QString::number(note->masterMark()->OwnPage +1);
+		else if (notesSet()->range() == NSRpage)
+			label += " on page " + QString::number(note->masterMark()->OwnPage +1);
+		else if (notesSet()->range() == NSRstory)
+			label += " in " + note->masterMark()->getItemPtr()->firstInChain()->itemName();
+		else if (notesSet()->range() == NSRframe)
+			label += " in frame " + note->masterMark()->getItemName();
+		mrk->label = label + "_" + note->numString();
+		mrk->setNotePtr(note);
+		getUniqueName(mrk->label, m_Doc->marksLabelsList(MARKNoteFrameType), "_");
+		note->setNoteMark(mrk);
+		m_Doc->m_docMarksList.append(mrk);
+	}
+	mrk->setItemPtr(this);
+
+	mrk->setString(notesSet()->prefix() + note->numString() + note->notesSet()->suffix());
+
+	//find position for inserting new note
+	int len = itemText.length();
+	if (index == 0)
+	{
+		itemText.insertMark(mrk,0);
+		if (len > 0)
+			itemText.insertChars(1, SpecialChars::PARSEP);
+		if (!note->saxedText().isEmpty())
+			itemText.insert(1, desaxeString(m_Doc, note->saxedText()));
+	}
+	else
+	{
+		int notesIndex = 0;
+		int pos;
+		for (pos=0; pos < len; ++pos)
+		{
+			ScText* hl = itemText.item(pos);
+			//inside footnote frame are available endnotes marks, so we must check if mark`s noteset is same as noteset of note
+			if (hl->hasMark() && hl->mark->isType(MARKNoteFrameType) && (hl->mark->getNotePtr()->notesSet() == note->notesSet()))
+			{
+				if (notesIndex == index)
+				{
+					itemText.insertMark(mrk,pos);
+					itemText.insertChars(pos +1, SpecialChars::PARSEP);
+					if (!note->saxedText().isEmpty())
+						itemText.insert(pos+1,desaxeString(m_Doc, note->saxedText()));
+					invalidateLayout();
+					return;
+				}
+				++notesIndex;
+			}
+		}
+		//inserting note at end of notes frame
+		itemText.insertChars(itemText.length(), SpecialChars::PARSEP);
+		itemText.insertMark(mrk, itemText.length());
+		if (!note->saxedText().isEmpty())
+			itemText.insert(itemText.length(), desaxeString(m_Doc, note->saxedText()));
+	}
+}
+
+void PageItem_NoteFrame::updateNotes(QList<TextNote*> nList, bool clear)
+{
+	if ((nList == l_notes) && !m_Doc->flag_notesChanged)
+		return; //seems nothig changes
+	m_Doc->flag_notesChanged = true;
+	itemText.blockSignals(true);
+
+	if (clear)
+	{
+		clearContents();
+		l_notes = nList;
+		for (int a=0; a < l_notes.count(); ++a)
+			insertNote(l_notes.at(a),a);
+	}
+	else
+	{
+		//just insert new notes into frame notes list
+		int count = nList.count();
+		if (count > 0)
+		{
+			for (int i=0; i< count; ++i)
+			{
+				TextNote* note = nList.at(i);
+				if (!l_notes.contains(note))
+				{
+					l_notes.append(note);
+					insertNote(note, note->num() -1);
+				}
+			}
+		}
+	}
+	itemText.blockSignals(false);
+	invalid = true;
+}
+
+void PageItem_NoteFrame::updateNotesText()
+{
+	//read texts from notes frame and copy it to note`s data
+	if (itemText.length() ==0)
+		return;
+
+	int oldSelStart = itemText.startOfSelection();
+	int oldSelLen = itemText.lengthOfSelection();
+
+	int pos = 0;
+	int startPos = 0;
+	TextNote *note = NULL;
+	Mark* prevMrk = NULL;
+	while (pos < itemText.length())
+	{
+		ScText* hl = itemText.item(pos);
+		if (hl->hasMark() && hl->mark->isType(MARKNoteFrameType))
+		{
+			if (prevMrk != NULL)
+			{
+				note = prevMrk->getNotePtr();
+				if (note != NULL)
+				{
+					int offset = 0;
+					if (itemText.text(pos-1) == SpecialChars::PARSEP)
+						++offset;
+					int len = pos - startPos -offset;
+					if (len <= 0)
+						note->setSaxedText("");
+					else
+						note->setSaxedText(getItemTextSaxed(startPos, len));
+					itemText.deselectAll();
+				}
+			}
+			prevMrk = hl->mark;
+			startPos = pos +1;
+		}
+		++pos;
+	}
+	note = prevMrk->getNotePtr();
+	if (startPos != pos && note != NULL)
+		note->setSaxedText(getItemTextSaxed(startPos, pos - startPos));
+	itemText.deselectAll();
+	if (oldSelLen > 0)
+		itemText.select(oldSelStart, oldSelLen);
+}
+
+int PageItem_NoteFrame::findNoteCpos(TextNote* note)
+{
+	//find position of note in note`s frame
+	if (itemText.length() == 0)
+		return -1;
+	for (int pos=0; pos < itemText.length(); ++pos)
+	{
+		ScText* hl = itemText.item(pos);
+		if (hl->hasMark() && hl->mark->isType(MARKNoteFrameType))
+		{
+			if (hl->mark->getNotePtr() == note)
+				return (pos);
+		}
+	}
+	return -1;
+}
diff --git a/Scribus/scribus/pageitem_noteframe.h b/Scribus/scribus/pageitem_noteframe.h
new file mode 100644
index 0000000..131fa6b
--- /dev/null
+++ b/Scribus/scribus/pageitem_noteframe.h
@@ -0,0 +1,61 @@
+#ifndef PAGEITEM_NOTEFRAME_H
+#define PAGEITEM_NOTEFRAME_H
+
+#include "pageitem_textframe.h"
+#include "notesset.h"
+#include "undostate.h"
+
+class PageItem_NoteFrame : public PageItem_TextFrame
+{
+		Q_OBJECT
+
+public:
+	PageItem_NoteFrame(NotesSet *nSet, ScribusDoc *doc, double x, double y, double w, double h, double w2, QString fill, QString outline);
+	PageItem_NoteFrame(ScribusDoc *doc, double x, double y, double w, double h, double w2, QString fill, QString outline);
+	PageItem_NoteFrame(PageItem_TextFrame* inFrame, NotesSet *nSet);
+	~PageItem_NoteFrame() {}
+
+	virtual PageItem_NoteFrame * asNoteFrame() { return this; }
+	virtual bool isNoteFrame() const { return true; }
+
+	//overloaded text frame layouting
+	void layout();
+
+	//indicate if noteframe should be deleted
+	bool deleteIt;
+
+	//used while reading SLA file
+	void setNS(NotesSet* nSet, PageItem_TextFrame* master = NULL);
+	//return Notes Set
+	NotesSet* notesSet() { return m_nset; }
+
+	//insert notes content into notesframe
+	void updateNotes(QList<TextNote*> nList, bool clear = true);
+	//read notes text from notesframe itemText and store it in notes`s saxed text field
+	void updateNotesText();
+
+	PageItem_TextFrame* masterFrame() { return m_masterFrame; }
+	void setMaster(PageItem* frame) { m_masterFrame = frame->asTextFrame(); }
+	bool isEndNotesFrame() { return m_nset->isEndNotes(); }
+	bool isAutoRemove() { return m_nset->isAutoRemoveEmptyNotesFrames(); }
+
+	//return list of notes in noteframe
+	QList<TextNote*> notesList() { return l_notes; }
+	//remove note from list
+	void removeNote(TextNote* note) { l_notes.removeOne(note); }
+
+private:
+	QList<TextNote*> l_notes;
+	NotesSet* m_nset;
+	PageItem_TextFrame *m_masterFrame;
+
+	//insert note at `index` position in noteframe
+	void insertNote(TextNote* note, int index = 0);
+
+//not used???
+	//find position of note marker in text
+	int findNoteCpos(TextNote* note);
+	
+};
+
+#endif // PAGEITEM_NOTEFRAME_H
diff --git a/Scribus/scribus/pageitem_textframe.cpp b/Scribus/scribus/pageitem_textframe.cpp
index b6a3548..ab471a1 100644
--- a/Scribus/scribus/pageitem_textframe.cpp
+++ b/Scribus/scribus/pageitem_textframe.cpp
@@ -35,9 +35,12 @@ for which a new license (GPL+exception) is in place.
 #include "canvas.h"
 #include "commonstrings.h"
 #include "hyphenator.h"
+#include "marks.h"
+#include "notesset.h"
 #include "pageitem.h"
 #include "pageitem_group.h"
 #include "pageitem_textframe.h"
+#include "pageitem_noteframe.h"
 #include "prefsmanager.h"
 #include "scpage.h"
 #include "scpainter.h"
@@ -54,6 +57,8 @@ for which a new license (GPL+exception) is in place.
 #include "util_math.h"
 
 #include "ui/guidemanager.h"
+//don`t worry - message boxes are called only if GUI is enabled
+#include "ui/scmessagebox.h"
 
 #include <cairo.h>
 
@@ -68,6 +73,7 @@ PageItem_TextFrame::PageItem_TextFrame(ScribusDoc *pa, double x, double y, doubl
 	unicodeTextEditMode = false;
 	unicodeInputCount = 0;
 	unicodeInputString = "";
+	lastVisibleGlyph = NULL;
 	
 	connect(&itemText,SIGNAL(changed()), this, SLOT(slotInvalidateLayout()));
 }
@@ -79,6 +85,8 @@ PageItem_TextFrame::PageItem_TextFrame(const PageItem & p) : PageItem(p)
 	unicodeTextEditMode = false;
 	unicodeInputCount = 0;
 	unicodeInputString = "";
+	m_notesFramesMap.clear();
+	lastVisibleGlyph = NULL;
 	
 	connect(&itemText,SIGNAL(changed()), this, SLOT(slotInvalidateLayout()));
 }
@@ -1159,8 +1167,8 @@ static double nextAutoTab (const LineControl &current, PageItem *item)
 	return res;
 }
 
-
-static double calculateLineSpacing (const ParagraphStyle &style, PageItem *item)
+//cezaryece: this function is used by PageItem_NoteFrame
+double calculateLineSpacing (const ParagraphStyle &style, PageItem *item)
 {
 	if (style.lineSpacingMode() == ParagraphStyle::AutomaticLineSpacing)
 	{
@@ -1340,7 +1348,8 @@ void PageItem_TextFrame::layout()
 	//hold Y position of last computed line of text (with glyphs descent)
 	//for moving next line if glyphs are higher than that
 	double lastLineY = 0;
-	
+	QMap<int, Mark*> noteMarksPosMap;  //maping notes marks and its position in text
+
 	// dump styles
 /*	
 	for (int i=0; i < itemText.nrOfParagraphs(); ++i) {
@@ -1353,6 +1362,19 @@ void PageItem_TextFrame::layout()
 */
 	
 	setShadow();
+	uint itLen = itemText.length();
+	//fast validate empty frames
+	if (itLen == 0 || firstChar == itLen)
+	{
+		PageItem* next = this;
+		while (next != NULL)
+		{
+			next->asTextFrame()->delAllNoteFrames();
+			next->invalid = false;
+			next = next->nextInChain();
+		}
+		return;
+	}
 	if ((itemText.length() != 0)) // || (NextBox != 0))
 	{
 		// determine layout area
@@ -1430,17 +1452,84 @@ void PageItem_TextFrame::layout()
 		setMaxY(-1);
 		double maxYAsc = 0.0, maxYDesc = 0.0;
 
+		//why emit invalidating signals each time text is changed by appling styles?
+		//this speed up layouting in case of using notes marks and drop caps
+		itemText.blockSignals(true);
+
 		for (int a = firstInFrame(); a < itemText.length(); ++a)
 		{
 			hl = itemText.item(a);
+			bool HasObject = hl->hasObject(m_Doc);
+			bool HasMark = hl->hasMark();
+			if (HasMark)
+			{
+				//show control characters for marks
+				hl->glyph.glyph = SpecialChars::OBJECT.unicode() + ScFace::CONTROL_GLYPHS;
+
+				hl->mark->OwnPage = OwnPage;
+				//itemPtr and itemName set to this frame only if mark type is different than MARK2ItemType
+				if (!hl->mark->isType(MARK2ItemType))
+				{
+					hl->mark->setItemPtr(this);
+					hl->mark->setItemName(itemName());
+				}
+				//anchors and indexes has no visible inserts in text
+				if (hl->mark->isType(MARKAnchorType) || hl->mark->isType(MARKIndexType))
+				{
+					hl->glyph.shrink();
+					continue;
+				}
+				//store mark pointer and position in text
+				if (hl->mark->isType(MARKNoteMasterType))
+					noteMarksPosMap.insert(a, hl->mark);
+				//set note marker charstyle
+				if (hl->mark->isNoteType())
+				{
+					hl->mark->setItemPtr(this);
+					TextNote* note = hl->mark->getNotePtr();
+						Q_ASSERT(note != NULL);
+					NotesSet* nSet = note->notesSet();
+						Q_ASSERT(nSet != NULL);
+					QString chsName = nSet->marksChStyle();
+					CharStyle newStyle(itemText.charStyle(a));
+					if ((chsName != "") && (chsName != tr("No Style")))
+					{
+						CharStyle marksStyle(m_Doc->charStyle(chsName));
+						if (!newStyle.equiv(marksStyle))
+						{
+							newStyle.setParent(chsName);
+							itemText.applyCharStyle(a, 1, marksStyle);
+						}
+					}
+					else
+						itemText.eraseCharStyle(a, 1, newStyle);
+					if (hl->mark->isType(MARKNoteMasterType))
+					{
+						if (nSet->isSuperscriptInMaster())
+							hl->setEffects(hl->effects() | ScStyle_Superscript);
+						else
+							hl->setEffects(hl->effects() & ~ScStyle_Superscript);
+					}
+					else
+					{
+						if (nSet->isSuperscriptInNote())
+							hl->setEffects(hl->effects() | ScStyle_Superscript);
+						else
+							hl->setEffects(hl->effects() & ~ScStyle_Superscript);
+					}
+				}
+			}
+			chstr = ExpandToken(a);
+			int chstrLen = chstr.length();
+			if (chstr.isEmpty())
+				chstr = SpecialChars::ZWNBSPACE;
+
 			curStat = SpecialChars::getCJKAttr(hl->ch);
 			if (a > 0 && itemText.text(a-1) == SpecialChars::PARSEP)
 				style = itemText.paragraphStyle(a);
 			if (current.itemsInLine == 0)
 				opticalMargins = style.opticalMargins();
-			
 			CharStyle charStyle = (hl->ch != SpecialChars::PARSEP? itemText.charStyle(a) : style.charStyle());
-			chstr = ExpandToken(a);
 			double hlcsize10 = charStyle.fontSize() / 10.0;
 			double scaleV = charStyle.scaleV() / 1000.0;
 			double scaleH = charStyle.scaleH() / 1000.0;
@@ -1477,7 +1566,7 @@ void PageItem_TextFrame::layout()
 					}
 					else if (charStyle.name() != style.dcCharStyleName())
 						charStyle.setStyle(m_Doc->charStyle(style.dcCharStyleName()));
-					itemText.setCharStyle(a, chstr.length(),charStyle);
+					itemText.setCharStyle(a, chstrLen ,charStyle);
 				}
 				else if (style.dcCharStyleName() != tr("No Style") && !style.dcCharStyleName().isEmpty())
 				//hasDropCap is cleared but is set dcCharStyleName = clear drop cap char style
@@ -1486,7 +1575,7 @@ void PageItem_TextFrame::layout()
 					CharStyle newStyle;
 					newStyle.setParent(m_Doc->paragraphStyle(curParent).charStyle().name());
 					charStyle.setStyle(newStyle);
-					itemText.setCharStyle(a, chstr.length(),charStyle);
+					itemText.setCharStyle(a, chstrLen ,charStyle);
 				}
 			}
 
@@ -1567,8 +1656,15 @@ void PageItem_TextFrame::layout()
 				// FIXME : we should ensure that fonts are loaded before calls to layout()
 				// ScFace::realCharHeight()/Ascent() ensure font is loaded thanks to an indirect call to char2CMap()
 				// ScFace::ascent() can be called safely afterwards
-				double realCharHeight = charStyle.font().realCharHeight(chstr[0], 1);
-				double realCharAscent = charStyle.font().realCharAscent(chstr[0], 1);
+
+				//text height, width, ascent and descent should be calculated for whole text provided by hl in current position
+				//and that may be more than one char (variable text for example)
+				double realCharHeight = 0.0, realCharAscent = 0.0;
+				for (int i = 0; i < chstrLen; ++i)
+				{
+					realCharHeight = qMax(realCharHeight, charStyle.font().realCharHeight(chstr[i], 1));
+					realCharAscent = qMax(realCharAscent, charStyle.font().realCharAscent(chstr[i], 1));
+				}
 				double fontAscent     = charStyle.font().ascent(style.charStyle().fontSize() / 10.0);
 				if (realCharHeight == 0.0)
 					realCharHeight = charStyle.font().height(style.charStyle().fontSize() / 10.0);
@@ -1578,7 +1674,7 @@ void PageItem_TextFrame::layout()
 				chs  = (10 * ((DropCapDrop + fontAscent) / realCharAscent));
 				hl->setEffects(hl->effects() | ScStyle_DropCap);
 				hl->glyph.yoffset -= DropCapDrop;
-				if ((hl->ch == SpecialChars::OBJECT) && (hl->hasObject(m_Doc)))
+				if (HasObject)
 				{
 					chs = qRound((hl->getItem(m_Doc)->height() + hl->getItem(m_Doc)->lineWidth()) * 10);
 					chsd = qRound((hl->getItem(m_Doc)->height() + hl->getItem(m_Doc)->lineWidth()) * 10);
@@ -1586,7 +1682,7 @@ void PageItem_TextFrame::layout()
 			}
 			else // ! dropCapMode
 			{
-				if ((hl->ch == SpecialChars::OBJECT) && (hl->hasObject(m_Doc)))
+				if (HasObject)
 					chs = qRound((hl->getItem(m_Doc)->height() + hl->getItem(m_Doc)->lineWidth()) * 10);
 				else
 					chs = charStyle.fontSize();
@@ -1605,7 +1701,7 @@ void PageItem_TextFrame::layout()
 			hl->glyph.yadvance = 0;
 			oldCurY = layoutGlyphs(*hl, chstr, hl->glyph);
 			// find out width, ascent and descent of char
-			if ((hl->ch == SpecialChars::OBJECT) && (hl->hasObject(m_Doc)))
+			if (HasObject)
 			{
 				wide = hl->getItem(m_Doc)->width() + hl->getItem(m_Doc)->lineWidth();
 				hl->glyph.xadvance = wide * hl->glyph.scaleH;
@@ -1701,7 +1797,7 @@ void PageItem_TextFrame::layout()
 			if (DropCmode)
 			{
 				// drop caps are wider...
-				if ((hl->ch == SpecialChars::OBJECT) && (hl->hasObject(m_Doc)))
+				if (HasObject)
 				{
 					double itemHeight = hl->getItem(m_Doc)->height() + hl->getItem(m_Doc)->lineWidth();
 					if (itemHeight == 0)
@@ -1715,11 +1811,19 @@ void PageItem_TextFrame::layout()
 				}
 				else
 				{
-					double realCharHeight = charStyle.font().realCharHeight(chstr[0], charStyle.fontSize() / 10.0);
+					double realCharHeight = 0.0;
+					wide = 0.0; realAsce = 0.0;
+					//
+					for (int i = 0; i < chstrLen; ++i)
+					{
+						realCharHeight = qMax(realCharHeight, charStyle.font().realCharHeight(chstr[i], charStyle.fontSize() / 10.0));
+						realAsce = qMax(realAsce, charStyle.font().realCharHeight(chstr[i], chsd / 10.0));
+						wide += charStyle.font().realCharWidth(chstr[i], chsd / 10.0);
+					}
+					wide = (wide* scaleH) + (1 - scaleH);
+					realAsce = realAsce  * scaleV + offset;
 					if (realCharHeight == 0)
 						realCharHeight = charStyle.font().height(style.charStyle().fontSize() / 10.0);
-					wide = (charStyle.font().realCharWidth(chstr[0], chsd / 10.0) * scaleH) + (1 - scaleH); //dropcaps are to close to next glyphs if glyphs are hard scaled
-					realAsce = charStyle.font().realCharHeight(chstr[0], chsd / 10.0) * scaleV + offset;
 					asce = charStyle.font().ascent(hlcsize10);
 					// qDebug() QString("dropcaps pre: chsd=%1 realCharHeight = %2 chstr=%3").arg(chsd).arg(asce).arg(chstr2[0]);
 					hl->glyph.scaleH /= hl->glyph.scaleV;
@@ -1739,15 +1843,22 @@ void PageItem_TextFrame::layout()
 					wide *= wordtracking;
 				}
 				// find ascent / descent
-				if ((hl->ch == SpecialChars::OBJECT) && (hl->hasObject(m_Doc)))
+				if (HasObject)
 					desc = realDesc = 0;
 				else
 				{
+					for (int i = 0; i < chstrLen; ++i)
+					{
+						if (chstr[i] == SpecialChars::OBJECT)
+							continue;
+						realDesc = qMax(realDesc, charStyle.font().realCharDescent(chstr[i], hlcsize10));
+						realAsce = charStyle.font().realCharAscent(chstr[i], hlcsize10);
+					}
+					realDesc =  realDesc * scaleV - offset;
 					desc = -charStyle.font().descent(hlcsize10);
-					realDesc = charStyle.font().realCharDescent(chstr[0], hlcsize10) * scaleV - offset;
 					current.rememberShrinkStretch(hl->ch, wide, style);
 				}
-				if ((hl->ch == SpecialChars::OBJECT) && (hl->hasObject(m_Doc)))
+				if (HasObject)
 				{
 					asce = hl->getItem(m_Doc)->height() + hl->getItem(m_Doc)->lineWidth();
 					realAsce = asce * scaleV + offset;
@@ -1755,7 +1866,13 @@ void PageItem_TextFrame::layout()
 				else
 				{
 					asce = charStyle.font().ascent(hlcsize10);
-					realAsce = charStyle.font().realCharAscent(chstr[0], hlcsize10) * scaleV + offset;
+					if (HasMark)
+						realAsce = asce * scaleV + offset;
+					else
+					{
+						for (int i = 0; i < chstrLen; ++i)
+							realAsce = qMax(realAsce, charStyle.font().realCharAscent(chstr[i], hlcsize10) * scaleV + offset);
+					}
 				}
 			}
 
@@ -1768,7 +1885,10 @@ void PageItem_TextFrame::layout()
 					if (current.startOfCol)
 					{
 						lastLineY = qMax(lastLineY, extra.Top + lineCorr);
-						if (style.lineSpacingMode() != ParagraphStyle::BaselineGridLineSpacing)
+						//fix for proper rendering first empty line (only with PARSEP)
+						if (chstr[0] == SpecialChars::PARSEP)
+							current.yPos += style.lineSpacing();
+						else if (style.lineSpacingMode() != ParagraphStyle::BaselineGridLineSpacing)
 						{
 							if (firstLineOffset() == FLOPRealGlyphHeight)
 							{
@@ -1980,14 +2100,14 @@ void PageItem_TextFrame::layout()
 					diff = realAsce - (current.yPos - lastLineY);
 				else if (style.lineSpacingMode() != ParagraphStyle::FixedLineSpacing)
 				{
-					if ((hl->ch == SpecialChars::OBJECT) && (hl->hasObject(m_Doc)))
+					if (HasObject)
 						diff = (hl->getItem(m_Doc)->height() + hl->getItem(m_Doc)->lineWidth()) * scaleV + offset - (current.yPos - lastLineY);
 					else
 						diff = charStyle.font().realCharAscent(QChar('l'), hlcsize10) * scaleV + offset - (current.yPos - lastLineY);
 				}
 				else
 				{
-					if ((hl->ch == SpecialChars::OBJECT) && (hl->hasObject(m_Doc)))
+					if (HasObject)
 						diff = (hl->getItem(m_Doc)->height() + hl->getItem(m_Doc)->lineWidth()) * scaleV + offset - (current.yPos - lastLineY);
 				}
 				if (diff >= 1 || (!DropCmode && diff > 0))
@@ -2100,7 +2220,12 @@ void PageItem_TextFrame::layout()
 			
 			// remember y pos
 			if (DropCmode)
-				hl->glyph.yoffset -= charStyle.font().realCharHeight(chstr[0], chsd / 10.0) - charStyle.font().realCharAscent(chstr[0], chsd / 10.0);
+			{
+				double yoffset = 0.0;
+				for (int i = 0; i < chstrLen; ++i)
+					yoffset = qMax(yoffset, charStyle.font().realCharHeight(chstr[i], chsd / 10.0) - charStyle.font().realCharAscent(chstr[i], chsd / 10.0));
+				hl->glyph.yoffset -= yoffset;
+			}
 
 			// remember x pos
 			double breakPos = current.xPos;
@@ -2126,7 +2251,7 @@ void PageItem_TextFrame::layout()
 					current.rememberBreak(a, breakPos, style.rightMargin());
 				}
 			}
-			if  ((hl->ch == SpecialChars::OBJECT) && (hl->hasObject(m_Doc)))
+			if  (HasObject)
 				current.rememberBreak(a, breakPos, style.rightMargin());
 			// CJK break
 			if(a > current.line.firstItem)
@@ -2554,7 +2679,7 @@ void PageItem_TextFrame::layout()
 						if (current.itemsInLine == 0 || current.column+1 == Cols)
 						{
 							goNoRoom = true;
-							MaxChars = a + 1;
+							MaxChars = a; // + 1;  - FIX ME - why +1 as in other places is =a;
 							break;
 						}
 						goNextColumn = true;
@@ -2648,7 +2773,7 @@ void PageItem_TextFrame::layout()
 				if (goNoRoom)
 				{
 					goNoRoom = false;
-					MaxChars = a+1;
+					MaxChars = a; //+1; - FIX ME - why +1 as in other places is =a;
 					goto NoRoom;
 				}
 				if (goNextColumn)
@@ -2769,34 +2894,52 @@ void PageItem_TextFrame::layout()
 
 			if (moveLinesFromPreviousFrame ()) {
 				layout ();  // line moving ensures that this won't be an endless loop
+				itemText.blockSignals(false);
 				return;
 			}
 		}
 	}
 	MaxChars = itemText.length();
+
+NoRoom:
 	invalid = false;
-	if (NextBox != NULL) 
+	adjustParagraphEndings ();
+
+	if (!isNoteFrame() && !m_Doc->m_docNotesList.isEmpty())
 	{
-		PageItem_TextFrame* nextFrame = dynamic_cast<PageItem_TextFrame*>(NextBox);
-		if (nextFrame != NULL)
-		{
-			nextFrame->invalid = true;
-			nextFrame->firstChar = MaxChars;
-		}
+		NotesInFrameMap notesMap = updateNotesFrames(noteMarksPosMap);
+		if (notesMap != m_notesFramesMap)
+			updateNotesMarks(notesMap);
+		if (!m_notesFramesMap.isEmpty() && m_Doc->flag_layoutNotesFrames)
+			notesFramesLayout(false);
 	}
-//	qDebug("textframe: len=%d, done relayout", itemText.length());
-	return;
-			
-NoRoom:     
-	invalid = false;
-
-	adjustParagraphEndings ();
 
 	PageItem_TextFrame * next = dynamic_cast<PageItem_TextFrame*>(NextBox);
 	if (next != NULL)
 	{
-		next->invalid = true;
-		next->firstChar = MaxChars;
+		//check if last visible glyph in frame change
+		//if not then do not force invalidation of next frame
+		ScText * lastGlyph = NULL;
+		if (MaxChars > 0)
+		{
+			uint pos = MaxChars-1;
+			lastGlyph = itemText.item(pos);
+			while (!lastGlyph->isVisible())
+				lastGlyph = itemText.item(--pos);
+		}
+		if ((lastGlyph != lastVisibleGlyph))
+		{
+			//force invalidating next frame
+			next->invalid = true;
+			// relayout next frame
+//			qDebug("textframe: len=%d, going to next", itemText.length());
+			next->layout();
+			next->firstChar = MaxChars;
+			lastVisibleGlyph = lastGlyph;
+			next->lastVisibleGlyph = NULL;
+		}
+		if (next->firstChar != MaxChars)
+			next->invalid = true;
 		if (itemText.cursorPosition() > signed(MaxChars))
 		{
 			int nCP = itemText.cursorPosition();
@@ -2811,17 +2954,16 @@ NoRoom:
 				return;
 			}
 		}
-		// relayout next frame
-//		qDebug("textframe: len=%d, going to next", itemText.length());
-		next->layout();
 	}
 //	qDebug("textframe: len=%d, done relayout (no room %d)", itemText.length(), MaxChars);
+	invalid = false; //to be sure
+	itemText.blockSignals(false);
 }
 
-void PageItem_TextFrame::invalidateLayout()
+void PageItem_TextFrame::invalidateLayout(bool wholeChain)
 {
-	const bool wholeChain = true;
-	this->invalid = true;
+	//const bool wholeChain = true;
+	invalid = true;
 	if (wholeChain)
 	{
 		PageItem *prevFrame = this->prevInChain();
@@ -2839,12 +2981,36 @@ void PageItem_TextFrame::invalidateLayout()
 	}
 }
 
+void PageItem_TextFrame::slotInvalidateLayout()
+{
+	invalidateLayout(true);
+}
+
+bool PageItem_TextFrame::isValidChainFromBegin()
+{
+	if (invalid)
+		return false;
+	if (BackBox == NULL)
+		return !invalid;
+
+	PageItem* prev = prevInChain();
+	while (prev != NULL)
+	{
+		if (prev->invalid)
+			return false;
+		prev = prev->prevInChain();
+	}
+	return true;
+}
+
 void PageItem_TextFrame::DrawObj_Item(ScPainter *p, QRectF cullingArea)
 {
-	if(invalid)
-		layout();
 	if (invalid)
-		return;
+	{
+		if (isNoteFrame() && asNoteFrame()->deleteIt)
+			return //do not layout notes frames which should be deleted
+		layout();
+	}
 	QTransform pf2;
 	QPoint pt1, pt2;
 	double wide, lineCorr;
@@ -2968,11 +3134,14 @@ void PageItem_TextFrame::DrawObj_Item(ScPainter *p, QRectF cullingArea)
 			{
 				bool selecteds = itemText.selected(as);
 				hls = itemText.item(as);
+				bool HasObject = hls->hasObject(m_Doc);
+				if (hls->mark != NULL && (hls->mark->isType(MARKAnchorType) || hls->mark->isType(MARKIndexType)))
+					continue;
 				if(selecteds)
 				{
 					const CharStyle& charStyleS(itemText.charStyle(as));
-					if(((as > ls.firstItem) && (charStyleS != itemText.charStyle(as-1)))
-						|| ((!selectedFrame.isNull()) && (hls->ch == SpecialChars::OBJECT))
+					if (((as > ls.firstItem) && (charStyleS != itemText.charStyle(as-1)))
+						|| ((!selectedFrame.isNull()) && HasObject)
 					    || previousWasObject)
 					{
 						sFList << selectedFrame;
@@ -2999,7 +3168,7 @@ void PageItem_TextFrame::DrawObj_Item(ScPainter *p, QRectF cullingArea)
 							asce = charStyleS.font().ascent(charStyleS.fontSize() / 10.0);
 							wide = hls->glyph.wide();
 							QRectF scr;
-							if ((hls->ch == SpecialChars::OBJECT)  && (hls->hasObject(m_Doc)))
+							if (HasObject)
 							{
 								double ww = (hls->getItem(m_Doc)->width() + hls->getItem(m_Doc)->lineWidth()) * hls->glyph.scaleH;
 								double hh = (hls->getItem(m_Doc)->height() + hls->getItem(m_Doc)->lineWidth()) * hls->glyph.scaleV;
@@ -3101,7 +3270,7 @@ void PageItem_TextFrame::DrawObj_Item(ScPainter *p, QRectF cullingArea)
 					{
 						p->save();//SA4
 						p->translate(CurX, ls.y);
-						if ((hl->ch == SpecialChars::OBJECT) && (hl->hasObject(m_Doc)))
+						if (hl->hasObject(m_Doc))
 							DrawObj_Embedded(p, cullingArea, charStyle, hl->getItem(m_Doc));
 						else
 							drawGlyphs(p, charStyle, hl->glyph);
@@ -3315,10 +3484,20 @@ void PageItem_TextFrame::DrawObj_Decoration(ScPainter *p)
 
 void PageItem_TextFrame::clearContents()
 {
-	PageItem *nextItem = this;
-	while (nextItem->prevInChain() != 0)
-		nextItem = nextItem->prevInChain();
+	PageItem *nextItem = this->firstInChain();
 
+	//delete all marks in itemText
+	for (int a=0; a < nextItem->itemText.length(); ++a)
+	{
+		ScText* hl = nextItem->itemText.item(a);
+		if (hl->hasMark() && hl->mark->isUnique())
+		{
+			if (isNoteFrame() && hl->mark->isNoteType())
+				continue;
+			m_Doc->eraseMark(hl->mark);
+			hl->mark = NULL;
+		}
+	}
 	ParagraphStyle defaultStyle = nextItem->itemText.defaultStyle();
 	nextItem->itemText.clear();
 	nextItem->itemText.setDefaultStyle(defaultStyle);
@@ -3326,6 +3505,7 @@ void PageItem_TextFrame::clearContents()
 	while (nextItem != 0)
 	{
 		nextItem->invalid = true;
+		nextItem->asTextFrame()->lastVisibleGlyph = NULL;
 		nextItem = nextItem->nextInChain();
 	}
 }
@@ -3366,6 +3546,73 @@ void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat)
 	}
 	int oldPos = itemText.cursorPosition(); // 15-mar-2004 jjsa for cursor movement with Shift + Arrow key
 	int kk = k->key();
+
+	//*****************************************
+	//check for deleting marks in selected text
+	bool marksDeleted = false;
+	QList<NotesSet*> ns2Update; //list of sets to do update after notes removing
+	
+	if (itemText.lengthOfSelection() > 0)
+	{ //overwriting selected text - check if selection contains marks
+		assert(itemText.startOfSelection() + itemText.lengthOfSelection() < itemText.length());  //cezaryece: I saw that situation
+		if (!k->text().isEmpty())
+		{
+			ScText* hl = NULL;
+			TextNote* note = selectedNoteMark(hl);
+			if (note != NULL)
+			{
+				if (m_Doc->hasGUI() &&
+					((ScMessageBox::warning( (QWidget*) m_Doc->scMW(), tr("Delete note(s)?"), tr("Do you want to delete whole note(s)?"),
+					 QMessageBox::Yes, QMessageBox::No | QMessageBox::Default, QMessageBox::NoButton)) != QMessageBox::Yes))
+				return;
+				while (note != NULL)
+				{
+					if (note->isEndNote())
+						m_Doc->flag_updateEndNotes = true;
+					ns2Update.append(note->notesSet());
+					hl->mark = NULL;
+					m_Doc->deleteNote(note);
+					note = selectedNoteMark(hl);
+				}
+			}
+			Mark* mrk = selectedMark();
+			while (mrk != NULL)
+			{
+				m_Doc->eraseMark(mrk);
+				mrk = selectedMark();
+				marksDeleted = true;
+			}
+		}
+	}
+	else if ((kk == Qt::Key_Delete) || (kk == Qt::Key_Backspace))
+	{ //deleting one char - check if it has note mark
+		ScText* hl = NULL;
+		//cursor before note number mark
+		if ((kk == Qt::Key_Delete) && (oldPos < itemText.length()))
+			hl = itemText.item(itemText.cursorPosition());
+		else if ((kk == Qt::Key_Backspace) && (oldPos >0)) 
+			hl = itemText.item(itemText.cursorPosition() -1);
+		if ((hl != NULL) && hl->hasMark())
+		{
+			Mark* mrk = hl->mark;
+			if (mrk->isType(MARKNoteMasterType) || mrk->isType(MARKNoteFrameType))
+			{
+				if ((ScMessageBox::question( (QWidget*) m_Doc->scMW(), tr("Delete note?"), tr("Do you realy want to delete this whole note?"),
+					QMessageBox::Yes, QMessageBox::No | QMessageBox::Default, QMessageBox::NoButton)) != QMessageBox::Yes)
+					return;
+				//deleting whole note
+				TextNote* note = mrk->getNotePtr();
+				if (note->isEndNote())
+					m_Doc->flag_updateEndNotes = true;
+				m_Doc->deleteNote(note);
+				ns2Update.append(note->notesSet());
+			}
+			else if (mrk->isUnique())
+				m_Doc->eraseMark(mrk);
+			hl->mark = NULL;
+			marksDeleted = true;
+		}
+	}
 	int as = k->text()[0].unicode();
 	QString uc = k->text();
 	QString cr, Tcha, Twort;
@@ -3437,6 +3684,8 @@ void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat)
 				itemText.insertChars(QString(QChar(conv)), true);
 //				Tinput = true;
 				m_Doc->scMW()->setTBvals(this);
+				if (marksDeleted)
+					m_Doc->updateMarks(true);
 				update();
 				keyRepeat = false;
 				return;
@@ -3725,6 +3974,12 @@ void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat)
 			if (itemText.lengthOfSelection() > 0)
 			{
 				deleteSelectedTextFromFrame();
+				while (!ns2Update.isEmpty())
+				{
+					NotesSet* ns = ns2Update.first();
+					m_Doc->updateNotesNums(ns);
+					ns2Update.removeAll(ns);
+				}
 				m_Doc->scMW()->setTBvals(this);
 				update();
 //				view->RefreshItem(this);
@@ -3741,6 +3996,12 @@ void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat)
 		if (itemText.lengthOfSelection() == 0)
 			itemText.select(itemText.cursorPosition(), 1, true);
 		deleteSelectedTextFromFrame();
+		while (!ns2Update.isEmpty())
+		{
+			NotesSet* ns = ns2Update.first();
+			m_Doc->updateNotesNums(ns);
+			ns2Update.removeAll(ns);
+		}
 		update();
 //		Tinput = false;
 		if ((cr == QChar(13)) && (itemText.length() != 0))
@@ -3757,6 +4018,12 @@ void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat)
 			if (itemText.lengthOfSelection() > 0)
 			{
 				deleteSelectedTextFromFrame();
+				while (!ns2Update.isEmpty())
+				{
+					NotesSet* ns = ns2Update.first();
+					m_Doc->updateNotesNums(ns);
+					ns2Update.removeAll(ns);
+				}
 				m_Doc->scMW()->setTBvals(this);
 				update();
 			}
@@ -3777,6 +4044,12 @@ void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat)
 //			m_Doc->chAbStyle(this, findParagraphStyle(m_Doc, itemText.paragraphStyle(qMax(CPos-1,0))));
 //			Tinput = false;
 		}
+		while (!ns2Update.isEmpty())
+		{
+			NotesSet* ns = ns2Update.first();
+			m_Doc->updateNotesNums(ns);
+			ns2Update.removeAll(ns);
+		}
 		updateLayout();
 		if (oldLast != lastInFrame() && NextBox != 0 && NextBox->invalid)
 			NextBox->updateLayout();
@@ -3866,6 +4139,12 @@ void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat)
 		{
 			// update layout immediately, we need MaxChars to be correct to detect 
 			// if we need to move to next frame or not
+			while (!ns2Update.isEmpty())
+			{
+				NotesSet* ns = ns2Update.first();
+				m_Doc->updateNotesNums(ns);
+				ns2Update.removeAll(ns);
+			}
 			updateLayout();
 			if (oldLast != lastInFrame() && NextBox != 0 && NextBox->invalid)
 				NextBox->updateLayout();
@@ -4195,8 +4474,40 @@ bool PageItem_TextFrame::createInfoGroup(QFrame *infoGroup, QGridLayout *infoGro
 	return true;
 }
 
+void PageItem_TextFrame::togleEditModeActions()
+{
+	bool editMode = (m_Doc->appMode == modeEdit);
+	bool masterMode = m_Doc->masterPageMode();
+	m_Doc->scMW()->scrActions["insertMarkVariableText"]->setEnabled(editMode);
+	m_Doc->scMW()->scrActions["insertMarkAnchor"]->setEnabled(editMode && !masterMode);
+	m_Doc->scMW()->scrActions["insertMarkItem"]->setEnabled(editMode && !masterMode);
+	m_Doc->scMW()->scrActions["insertMark2Mark"]->setEnabled(editMode && !masterMode);
+	m_Doc->scMW()->scrActions["insertMarkNote"]->setEnabled(editMode && !masterMode && !isNoteFrame());
+	//	scrActions["insertMarkIndex"]->setEnabled(editMode && !masterMode);
+	bool enableEditMark = false;
+	if (editMode && (itemText.cursorPosition() < itemText.length()))
+	{
+		ScText *hl = itemText.item(itemText.cursorPosition());
+		if (hl->hasMark())
+		{
+			Mark* mrk = hl->mark;
+			//notes marks in note frames are not editable
+			if (!mrk->isType(MARKNoteFrameType))
+				enableEditMark = true;
+		}
+	}
+	m_Doc->scMW()->scrActions["editMark"]->setEnabled(enableEditMark);
+	m_Doc->scMW()->scrActions["itemUpdateMarks"]->setEnabled(hasAnyMark());
+}
+
 void PageItem_TextFrame::applicableActions(QStringList & actionList)
 {
+	actionList << "insertMarkVariableText";
+	if (!m_Doc->masterPageMode())
+		actionList << "insertMarkAnchor";
+	//notes frames are not simply text frames
+	if (isNoteFrame())
+		return;
 	actionList << "fileImportText";
 	actionList << "fileImportAppendText";
 	actionList << "toolsEditWithStoryEditor";
@@ -4229,9 +4540,398 @@ QString PageItem_TextFrame::infoDescription()
 	return QString();
 }
 
-void PageItem_TextFrame::slotInvalidateLayout()
+bool PageItem_TextFrame::hasMark(NotesSet *NS)
+{
+	if (isNoteFrame())
+		return false;
+	if (NS == NULL)
+		return hasAnyMark();
+	for (int pos = firstInFrame(); pos <= lastInFrame(); ++pos)
+	{
+		ScText* hl = itemText.item(pos);
+		if (hl->hasMark())
+		{
+			TextNote* note = hl->mark->getNotePtr();
+			if (note != NULL)
+			{
+				NotesSet* ns = note->notesSet();
+				if (ns == NS)
+					return true;
+			}
+		}
+	}
+	return false;
+}
+
+bool PageItem_TextFrame::hasNoteFrame(NotesSet *NS, bool inChain)
+{
+	if (isNoteFrame())
+		return false;
+	if (m_notesFramesMap.isEmpty())
+		return false;
+	if (NS == NULL)
+	{ //check if any notes are in frame or whole chain
+		if (!inChain)
+			return !m_notesFramesMap.isEmpty();
+		else
+		{
+			PageItem* item = this;
+			item = firstInChain();
+			while (item != NULL)
+			{
+				if (item->asTextFrame()->hasNoteFrame(NULL, false))
+					return true;
+				item = item->nextInChain();
+			}
+			return false;
+		}
+	}
+	PageItem* item = this;
+	if (inChain)
+		item = firstInChain();
+	while (item != NULL)
+	{
+		QMap<PageItem_NoteFrame*, QList<TextNote*> >::iterator it = m_notesFramesMap.begin();
+		QMap<PageItem_NoteFrame*, QList<TextNote*> >::iterator end = m_notesFramesMap.end();
+		while (it != end)
+		{
+			if (it.key()->notesSet() == NS)
+				return true;
+			++it;
+		}
+		if (!inChain)
+			item = NULL;
+		item = item->nextInChain();
+	}
+	return false;
+}
+
+void PageItem_TextFrame::delAllNoteFrames(bool doUpdate)
+{
+	int oldItemsCount = m_Doc->Items->count();
+
+	QList<PageItem_NoteFrame*> tempList = m_notesFramesMap.keys();
+	QList<PageItem_NoteFrame*> delList;
+	foreach (PageItem_NoteFrame* nF, tempList)
+	{
+		if ((nF != NULL) && !nF->isEndNotesFrame())
+			delList.append(nF);
+	}
+	while (!delList.isEmpty())
+	{
+		PageItem_NoteFrame* nF = delList.takeFirst();
+		m_Doc->delNoteFrame(nF);
+	}
+
+	//check if doc need update
+	if (doUpdate && (oldItemsCount != m_Doc->Items->count()))
+	{
+		m_Doc->changed();
+		m_Doc->regionsChanged()->update(QRectF());
+	}
+	m_Doc->flag_notesChanged = true;
+}
+
+Mark* PageItem_TextFrame::selectedMark(bool onlySelection)
+{ //return pointer to first mark in selected (or whole) text
+	
+	bool omitNotes = true; //do not return notes marks (for searching notes use selectedNotesMark()
+	int start = 0;
+	int stop = itemText.length() -1;
+	if (HasSel && onlySelection)
+	{
+		//only selection
+		start = itemText.startOfSelection();
+		stop = start + itemText.lengthOfSelection();
+	}
+
+	for (int pos = start; pos < stop; ++pos)
+	{
+		ScText* hl = itemText.item(pos);
+		if (hl->hasMark())
+		{
+			if (omitNotes && (hl->mark->isType(MARKNoteMasterType) || hl->mark->isType(MARKNoteFrameType)))
+				continue;
+			return hl->mark;
+		}
+	}
+	return NULL;
+}
+
+TextNote* PageItem_TextFrame::selectedNoteMark(ScText* &hl, bool onlySelection)
+{
+	//return pointer to note from first mark found in text
+	int start = 0;
+	int stop = itemText.length() -1;
+	if (HasSel && onlySelection)
+	{
+		//only selection
+		start = itemText.startOfSelection();
+		stop = start + itemText.lengthOfSelection();
+	}
+	
+	MarkType typ = isNoteFrame()? MARKNoteFrameType : MARKNoteMasterType;
+	for (int pos = start; pos < stop; ++pos)
+	{
+		hl = itemText.item(pos);
+		if (hl->hasMark() && hl->mark->isType(typ))
+			return hl->mark->getNotePtr();
+	}
+	return NULL;
+}
+
+TextNote* PageItem_TextFrame::selectedNoteMark(bool onlySelection)
+{
+	ScText* hl = NULL;
+	return selectedNoteMark(hl, onlySelection);
+}
+
+NotesInFrameMap PageItem_TextFrame::updateNotesFrames(QMap<int, Mark*> noteMarksPosMap)
+{
+	NotesInFrameMap notesMap; //= m_notesFramesMap;
+	QMap<int, Mark*>::Iterator it = noteMarksPosMap.begin();
+	QMap<int, Mark*>::Iterator end = noteMarksPosMap.end();
+	while (it != end)
+	{
+		if (it.key() <= lastInFrame())
+		{
+			Mark* mark = it.value();
+			mark->setItemPtr(this);
+			mark->setItemName(itemName());
+
+			TextNote* note = mark->getNotePtr();
+			Q_ASSERT(note != NULL);
+			if (note == NULL)
+			{
+				qWarning() << "note mark without valid note pointer";
+				note = new TextNote(m_Doc->m_docNotesSetsList.at(0));
+				note->setMasterMark(mark);
+				mark->setNotePtr(note);
+			}
+			NotesSet* NS = note->notesSet();
+			PageItem_NoteFrame* nF = NULL;
+			if (NS->isEndNotes())
+				nF = m_Doc->endNoteFrame(NS, this);
+			else
+				nF = itemNoteFrame(NS);
+			if (nF == NULL)
+			{
+				//creating new noteframe
+				if (NS->isEndNotes())
+				{
+					//create new endnotes frame
+					double x,y,w,h;
+					const ScPage* scP = m_Doc->page4EndNotes(NS, this);
+					x = scP->Margins.Left + m_Doc->rulerXoffset + scP->xOffset();
+					y = scP->Margins.Top + m_Doc->rulerYoffset + scP->yOffset();
+					w = scP->width() - scP->Margins.Left - scP->Margins.Right;
+					h = calculateLineSpacing(itemText.defaultStyle(), this);
+					nF = new PageItem_NoteFrame(note->notesSet(), m_Doc, x, y, w, h, m_Doc->itemToolPrefs().shapeLineWidth, CommonStrings::None, m_Doc->itemToolPrefs().textFont);
+					m_Doc->DocItems.append(nF);
+					m_Doc->flag_notesChanged = true;
+					switch (NS->range())
+					{ //insert pointer to endnoteframe into m_Doc->m_endNotesFramesMap
+						case NSRdocument:
+							m_Doc->setEndNoteFrame(nF, (void*) NULL);
+							break;
+						case NSRsection:
+							m_Doc->setEndNoteFrame(nF, m_Doc->getSectionKeyForPageIndex(OwnPage));
+						case NSRstory:
+							m_Doc->setEndNoteFrame(nF, (void*) firstInChain());
+							break;
+						case NSRpage:
+							m_Doc->setEndNoteFrame(nF, (void*) m_Doc->DocPages.at(OwnPage));
+							break;
+					}
+				}
+				else
+				{
+					//create new footnotes frame for that text frame
+					nF = new PageItem_NoteFrame(this, note->notesSet());
+					m_Doc->DocItems.insert(m_Doc->DocItems.indexOf(this), nF);
+					m_Doc->flag_notesChanged = true;
+				}
+				//insert in map noteframe with empty list of notes
+				m_notesFramesMap.insert(nF, QList<TextNote*>());
+			}
+			QList<TextNote*> nList;//list of notes in current noteFrame
+			nList = notesMap.value(nF);
+			if (!nList.contains(note))
+			{
+				nList.append(note);
+				notesMap.insert(nF, nList);
+			}
+		}
+		else
+			break;
+		++it;
+	}
+	return notesMap;
+}
+
+void PageItem_TextFrame::updateNotesMarks(NotesInFrameMap notesMap)
+{
+	bool docWasChanged = false;
+
+	QList<PageItem_NoteFrame*> footNotesList;
+	QList<PageItem_NoteFrame*> m_footNotesList;
+	QList<PageItem_NoteFrame*> endNotesList;
+	QList<PageItem_NoteFrame*> m_endNotesList;
+	foreach(PageItem_NoteFrame* nF, notesMap.keys())
+	{
+		if (nF->isEndNotesFrame())
+			endNotesList.append(nF);
+		else
+			footNotesList.append(nF);
+	}
+	foreach(PageItem_NoteFrame* nF, m_notesFramesMap.keys())
+	{
+		if (nF->isEndNotesFrame())
+			m_endNotesList.append(nF);
+		else
+			m_footNotesList.append(nF);
+	}
+
+	//check for endnotes marks change in current frame
+	foreach (PageItem_NoteFrame* nF, m_endNotesList)
+	{
+		if (!notesMap.contains(nF) || (m_notesFramesMap.value(nF) != notesMap.value(nF)))
+		{
+			m_Doc->endNoteFrameChanged(nF);
+			docWasChanged = true;
+		}
+	}
+	foreach (PageItem_NoteFrame* nF, endNotesList)
+	{
+		if (!m_notesFramesMap.contains(nF) || (m_notesFramesMap.value(nF) != notesMap.value(nF)))
+		{
+			m_Doc->endNoteFrameChanged(nF);
+			docWasChanged = true;
+		}
+	}
+
+	//check if some footnotes frames are not used anymore
+	foreach (PageItem_NoteFrame* nF, m_footNotesList)
+	{
+		if (nF->isAutoRemove() && (!notesMap.contains(nF) || notesMap.value(nF).isEmpty()))
+		{
+			nF->deleteIt = true;
+			docWasChanged = true;
+		}
+	}
+
+	//update footnotes
+	foreach (PageItem_NoteFrame* nF, footNotesList)
+	{
+		if (nF->deleteIt)
+			continue;
+
+		QList<TextNote*> nList = notesMap.value(nF);
+		if (nList != nF->notesList() || m_Doc->flag_notesChanged)
+		{
+			nF->updateNotes(nList);
+			docWasChanged = true;
+		}
+	}
+
+	//delete footnotes frames marked as for remove
+	foreach (PageItem_NoteFrame* noteFrame, m_footNotesList)
+	{
+		if (noteFrame->deleteIt)
+		{
+			//delete note frame only if not is edited right now
+			if ( !noteFrame->isSelected() || (m_Doc->appMode != modeEdit))
+				m_Doc->delNoteFrame(noteFrame,true);
+			else
+			{
+				m_Doc->view()->Deselect(true);
+				m_Doc->view()->requestMode(modeNormal);
+			}
+			docWasChanged = true;
+		}
+	}
+	
+	if (m_notesFramesMap != notesMap)
+	{
+		docWasChanged = true;
+		m_notesFramesMap = notesMap;
+	}
+	if (docWasChanged)
+	{
+		m_Doc->flag_restartMarksRenumbering = true;
+		m_Doc->flag_notesChanged = true;
+	}
+}
+
+void PageItem_TextFrame::notesFramesLayout(bool force)
+{
+	foreach (PageItem_NoteFrame* nF, m_notesFramesMap.keys())
+	{
+		if (nF == NULL)
+			continue;
+		if (nF->deleteIt)
+			continue;
+		if (nF->isEndNotesFrame() && m_Doc->flag_updateEndNotes)
+			m_Doc->updateEndNotesFrameContent(nF);
+		if (force)
+			nF->invalid = true;
+		nF->layout();
+	}
+}
+
+bool PageItem_TextFrame::removeMarksFromText(bool force)
+{
+	//check if in selected (or whole) text are any marks for removing
+	//if notes are found then ask user if he want to removing notes
+	//returns false if user don`t accept removing notes
+	//in marksDeleted return if any marks was deleted
+
+	//but not for notesframe
+	if (!isNoteFrame())
+	{
+		//list of notes sets to update after removing notes
+		QList<NotesSet*> ns2Update;
+		
+		TextNote* note = selectedNoteMark();
+		if (note != NULL)
+		{
+			if ((m_Doc->hasGUI() && !force)
+				&& (ScMessageBox::warning( (QWidget*) m_Doc->scMW(), tr("Delete note(s)?"), tr("Do you want to delete whole note(s)?"),
+										   QMessageBox::Yes, QMessageBox::No | QMessageBox::Default, QMessageBox::NoButton) != QMessageBox::Yes))
+				return false;
+			while (note != NULL)
+			{
+				ns2Update.append(note->notesSet());
+				m_Doc->deleteNote(note);
+				note = selectedNoteMark();
+			}
+			m_Doc->flag_notesChanged = true;
+		}
+		
+		while (!ns2Update.isEmpty())
+		{
+			NotesSet* ns = ns2Update.first();
+			m_Doc->updateNotesNums(ns);
+			ns2Update.removeAll(ns);
+		}
+	}
+	
+	Mark* mrk = selectedMark();
+	while (mrk != NULL)
+	{
+		m_Doc->eraseMark(mrk, true, this);
+		mrk = selectedMark();
+		//marksDeleted = true;
+	}
+	return true;
+}
+
+PageItem_NoteFrame *PageItem_TextFrame::itemNoteFrame(NotesSet *nSet)
 {
-	invalidateLayout();
+	foreach (PageItem_NoteFrame* nF, m_notesFramesMap.keys())
+		if (nF->notesSet() == nSet)
+			return nF;
+	return NULL;
 }
 
 void PageItem_TextFrame::setMaxY(double y)
diff --git a/Scribus/scribus/pageitem_textframe.h b/Scribus/scribus/pageitem_textframe.h
index 50bd63d..a0db8fe 100644
--- a/Scribus/scribus/pageitem_textframe.h
+++ b/Scribus/scribus/pageitem_textframe.h
@@ -29,10 +29,15 @@ for which a new license (GPL+exception) is in place.
 
 #include "scribusapi.h"
 #include "pageitem.h"
+#include "notesset.h"
+#include "marks.h"
 
+class PageItem_NoteFrame;
 class ScPainter;
 class ScribusDoc;
 
+typedef QMap<PageItem_NoteFrame*, QList<TextNote *> > NotesInFrameMap;
+
 #include "text/nlsconfig.h"
 
 #ifdef NLS_PROTO
@@ -43,6 +48,9 @@ class ScText;
 class ScStyleRun;
 #endif
 
+//cezaryece: used by PageItem_NoteFrame
+double calculateLineSpacing (const ParagraphStyle &style, PageItem *item);
+
 class SCRIBUS_API PageItem_TextFrame : public PageItem
 {
 	Q_OBJECT
@@ -67,16 +75,25 @@ public:
 	void setNewPos(int oldPos, int len, int dir);
 	void ExpandSel(int dir, int oldPos);
 	void deselectAll();
-	
-	virtual void invalidateLayout();
+
+	//for speed up updates when changed was only one frame from chain
+	virtual void invalidateLayout(bool wholeChain = false);
 	virtual void layout();
+	//return true if all previouse frames from chain are valid (including that one)
+	bool isValidChainFromBegin();
+	//simplify conditions checking if frame is in chain
+	//FIX: use it in other places
+	bool isInChain() { return ((prevInChain() != NULL) || (nextInChain() != NULL)); }
 
 	double columnWidth();
 #ifdef NLS_PROTO
 	int firstTextItem() const { return itemText.firstFrameItem; }
 	int lastTextItem() const { return itemText.lastFrameItem; }
 #endif
+	//enable/disable marks inserting actions depending on editMode
+	void togleEditModeActions();
 	QRegion availableRegion() { return m_availableRegion; }
+
 protected:
 	QRegion calcAvailableRegion();
 	QRegion m_availableRegion;
@@ -102,6 +119,7 @@ protected:
 	// Move incomplete lines from the previous frame if needed.
 	bool moveLinesFromPreviousFrame ();
 	void adjustParagraphEndings ();
+	ScText * lastVisibleGlyph; //storing last visible glyph in text frame - if it not change then dont force invalidating next frame
 
 private:
 	bool cursorBiasBackward;
@@ -125,6 +143,35 @@ public:
 
 private slots:
 	void slotInvalidateLayout();
-};
 
+public:
+	//for footnotes/endnotes
+	bool hasAnyMark() { return ((selectedMark(false) != NULL) || (selectedNoteMark(false) != NULL)); }
+	bool hasMark(NotesSet* NS);
+	bool hasNoteFrame(NotesSet* NS, bool inChain = false);
+	bool hasNoteFrame(PageItem_NoteFrame* nF) { return m_notesFramesMap.contains(nF); }
+	//PageItem_NoteFrame* itemNoteFrame(NotesSet* NS) const;
+	void delAllNoteFrames(bool doUpdate = false);
+	void delNoteFrame(PageItem_NoteFrame* nF) { m_notesFramesMap.remove(nF); }
+	//layout notes frames /updates endnotes frames content if m_Doc->flag_updateEndNotes is set/
+	void notesFramesLayout(bool force);
+	//removing all marsk from text, if not force and is GUI enabled then user will be warned
+	bool removeMarksFromText(bool force=false);
+	//return note frame for given notes set if current text frame has notes marks with this notes set
+	PageItem_NoteFrame* itemNoteFrame(NotesSet* nSet);
+	//list all notes frames for current text frame /with endnotes frames if endnotes marks are in that frame/
+	QList<PageItem_NoteFrame*> notesFramesList() { return m_notesFramesMap.keys(); }
+	//list of notes inserted by current text frame into given noteframe
+	QList<TextNote*> notesList(PageItem_NoteFrame* nF) { return m_notesFramesMap.value(nF); }
+	//insert note frame to list with empty notes list
+	void setNoteFrame(PageItem_NoteFrame* nF) { m_notesFramesMap.insert(nF, QList<TextNote*>()); }
+
+private:
+	NotesInFrameMap m_notesFramesMap;
+	NotesInFrameMap updateNotesFrames(QMap<int, Mark*> noteMarksPosMap); //update notes frames content
+	void updateNotesMarks(NotesInFrameMap notesMap);
+	Mark* selectedMark(bool onlySelection = true);
+	TextNote* selectedNoteMark(ScText* &hl, bool onlySelection = true);
+	TextNote* selectedNoteMark(bool onlySelection = true);
+};
 #endif
diff --git a/Scribus/scribus/pagestructs.h b/Scribus/scribus/pagestructs.h
index 5f66292..74571ed 100644
--- a/Scribus/scribus/pagestructs.h
+++ b/Scribus/scribus/pagestructs.h
@@ -48,9 +48,12 @@ typedef enum
 	Type_I_II_III,
 	Type_a_b_c,
 	Type_A_B_C,
+	Type_asterix,
 	Type_None=99
 } DocumentSectionType;
 
+typedef DocumentSectionType NumerationType;
+
 struct DocumentSection
 {
 	uint number; //Just an index in the section list
diff --git a/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp b/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
index 22ed7ad..d00bac7 100644
--- a/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
+++ b/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
@@ -11,7 +11,9 @@ for which a new license (GPL+exception) is in place.
 #include "commonstrings.h"
 #include "ui/missing.h"
 #include "hyphenator.h"
+#include "notesset.h"
 #include "pageitem_latexframe.h"
+#include "pageitem_noteframe.h"
 #include "prefsmanager.h"
 #include "scclocale.h"
 #include "scconfig.h"
@@ -27,6 +29,7 @@ for which a new license (GPL+exception) is in place.
 #include "util.h"
 #include "util_math.h"
 #include "util_color.h"
+#include "util_text.h"
 #include "scgzfile.h"
 #ifdef HAVE_OSG
 	#include "pageitem_osgframe.h"
@@ -35,6 +38,7 @@ for which a new license (GPL+exception) is in place.
 #include "pageitem_regularpolygon.h"
 #include "pageitem_arc.h"
 #include "pageitem_spiral.h"
+#include "pagestructs.h"
 #include <QCursor>
 // #include <QDebug>
 #include <QFileInfo>
@@ -385,6 +389,26 @@ bool Scribus150Format::loadElements(const QString & data, QString fileDir, int t
 			success = readPattern(m_Doc, reader, fileDir);
 			if (!success) break;
 		}
+		if (tagName == "NotesSets")
+		{
+			success = readNotesSets(m_Doc, reader);
+			if (!success) break;
+		}
+		if (tagName == "NotesFrames")
+		{
+			success = readNotesFrames(reader);
+			if (!success) break;
+		}
+		if (tagName == "Notes")
+		{
+			success = readNotes(m_Doc, reader);
+			if (!success) break;
+		}
+		if (tagName == "Marks")
+		{
+			success = readMarks(m_Doc, reader);
+			if (!success) break;
+		}
 	}
 	if (reader.hasError())
 	{
@@ -860,6 +884,26 @@ bool Scribus150Format::loadPalette(const QString & fileName)
 			success = readPattern(m_Doc, reader, fileDir);
 			if (!success) break;
 		}
+		if (tagName == "NotesSets")
+		{
+			success = readNotesSets(m_Doc, reader);
+			if (!success) break;
+		}
+		if (tagName == "NotesFrames")
+		{
+			success = readNotesFrames(reader);
+			if (!success) break;
+		}
+		if (tagName == "Notes")
+		{
+			success = readNotes(m_Doc, reader);
+			if (!success) break;
+		}
+		if (tagName == "Marks")
+		{
+			success = readMarks(m_Doc, reader);
+			if (!success) break;
+		}
 	}
 
 	if (reader.hasError())
@@ -1180,6 +1224,13 @@ bool Scribus150Format::loadFile(const QString & fileName, const FileFormat & /*
 	QStack< QList<PageItem*> > groupStackP;
 	QStack<int> groupStack2;
 	
+	markeredItemsMap.clear();
+	markeredMarksMap.clear();
+	nsetRangeItemNamesMap.clear();
+	notesFramesData.clear();
+	notesMasterMarks.clear();
+	notesNSets.clear();
+	
 	QString f(readSLA(fileName));
 	if (f.isEmpty())
 	{
@@ -1495,6 +1546,26 @@ bool Scribus150Format::loadFile(const QString & fileName, const FileFormat & /*
 			if (!success)
 				break;
 		}
+		if (tagName == "NotesSets")
+		{
+			success = readNotesSets(m_Doc, reader);
+			if (!success) break;
+		}
+		if (tagName == "NotesFrames")
+		{
+			success = readNotesFrames(reader);
+			if (!success) break;
+		}
+		if (tagName == "Notes")
+		{
+			success = readNotes(m_Doc, reader);
+			if (!success) break;
+		}
+		if (tagName == "Marks")
+		{
+			success = readMarks(m_Doc, reader);
+			if (!success) break;
+		}
 	}
 
 	if (reader.hasError())
@@ -1802,6 +1873,8 @@ bool Scribus150Format::loadFile(const QString & fileName, const FileFormat & /*
 				gItem->groupItemList = gpL;
 		}
 	}
+	//update names to pointers
+	updateNames2Ptr();
 	
 	// reestablish first/lastAuto
 	m_Doc->FirstAuto = m_Doc->LastAuto;
@@ -3077,6 +3150,169 @@ bool Scribus150Format::readTableOfContents(ScribusDoc* doc, ScXmlStreamReader& r
 	return !reader.hasError();
 }
 
+bool Scribus150Format::readNotesSets(ScribusDoc* doc, ScXmlStreamReader& reader)
+{
+	QStringRef tagName = reader.name();
+	while(!reader.atEnd() && !reader.hasError())
+	{
+		reader.readNext();
+		if (reader.isEndElement() && reader.name() == tagName)
+			break;
+		//read notes sets
+		if (reader.isStartElement() && reader.name() == "notesSet")
+		{
+			ScXmlStreamAttributes attrs = reader.scAttributes();
+			NotesSet NS;
+			NS.setName(attrs.valueAsString("Name"));
+			NS.setStart(attrs.valueAsInt("Start"));
+			NS.setEndNotes(attrs.valueAsBool("Endnotes"));
+			QString type = attrs.valueAsString("Type");
+			if (type == "Type_1_2_3")
+				NS.setType(Type_1_2_3);
+			else if (type == "Type_i_ii_iii")
+				NS.setType(Type_i_ii_iii);
+			else if (type == "Type_I_II_III")
+				NS.setType(Type_I_II_III);
+			else if (type == "Type_a_b_c")
+				NS.setType(Type_a_b_c);
+			else if (type == "Type_A_B_C")
+				NS.setType(Type_A_B_C);
+			else if (type == "Type_asterix")
+				NS.setType(Type_asterix);
+			else //if (type == "Type_None")
+				NS.setType(Type_None);
+			NS.setRange((NumerationRange) attrs.valueAsInt("Range"));
+			NS.setPrefix(attrs.valueAsString("Prefix"));
+			NS.setSuffix(attrs.valueAsString("Suffix"));
+			NS.setAutoNotesHeight(attrs.valueAsBool("AutoHeight"));
+			NS.setAutoNotesWidth(attrs.valueAsBool("AutoWidth"));
+			NS.setAutoRemoveEmptyNotesFrames(attrs.valueAsBool("AutoRemove"));
+			NS.setAutoWeldNotesFrames(attrs.valueAsBool("AutoWeld"));
+			NS.setSuperscriptInNote(attrs.valueAsBool("SuperNote"));
+			NS.setSuperscriptInMaster(attrs.valueAsBool("SuperMaster"));
+			NS.setMarksCharStyle("");
+			NS.setNotesParStyle("");
+			QString name;
+			name = attrs.valueAsString("MarksStyle");
+			if (!name.isEmpty())
+				NS.setMarksCharStyle(name);
+			name = attrs.valueAsString("NotesStyle");
+			if (!name.isEmpty())
+				NS.setNotesParStyle(name);
+
+			m_Doc->newNotesSet(NS);
+		}
+	}
+	return !reader.hasError();
+}
+
+bool Scribus150Format::readNotesFrames(ScXmlStreamReader& reader)
+{
+	notesFramesData.clear();
+	QStringRef tagName = reader.name();
+	while(!reader.atEnd() && !reader.hasError())
+	{
+		reader.readNext();
+		if (reader.isEndElement() && reader.name() == tagName)
+			break;
+		if (reader.isStartElement())
+		{
+			ScXmlStreamAttributes attrs = reader.scAttributes();
+			NoteFrameData eF;
+			eF.NSname = attrs.valueAsString("NSname");
+			eF.myID = attrs.valueAsInt("myID");
+			if (reader.name() == "ENDNOTEFRAME")
+			{
+				eF.index = attrs.valueAsInt("index");
+				eF.NSrange = (NumerationRange) attrs.valueAsInt("range");
+				eF.itemID = attrs.valueAsInt("ItemID");
+			}
+			if (reader.name() == "FOOTNOTEFRAME")
+				eF.itemID = attrs.valueAsInt("MasterID");
+			notesFramesData.append(eF);
+		}
+	}
+	return !reader.hasError();
+}
+
+bool Scribus150Format::readNotes(ScribusDoc* doc, ScXmlStreamReader& reader)
+{
+	//read notes
+	QStringRef tagName = reader.name();
+	while(!reader.atEnd() && !reader.hasError())
+	{
+		reader.readNext();
+		if (reader.isEndElement() && reader.name() == tagName)
+			break;
+		if (reader.isStartElement() && reader.name() == "Note")
+		{
+			ScXmlStreamAttributes attrs = reader.scAttributes();
+			TextNote* note = new TextNote(NULL);
+			doc->m_docNotesList.append(note);
+			note->setSaxedText(attrs.valueAsString("Text"));
+			//temporaly insert names of master mark and notesset into maps with note pointer
+			//will be resolved to pointers by updateNames2Ptr() after all will read
+			notesMasterMarks.insert(attrs.valueAsString("Master"), note);
+			notesNSets.insert(note, attrs.valueAsString("NSet"));
+		}
+	}
+	return !reader.hasError();
+}
+
+bool Scribus150Format::readMarks(ScribusDoc* doc, ScXmlStreamReader& reader)
+{
+	QStringRef tagName = reader.name();
+	while(!reader.atEnd() && !reader.hasError())
+	{
+		reader.readNext();
+		if (reader.isEndElement() && reader.name() == tagName)
+			break;
+		if(reader.isStartElement() && reader.name() == "Mark")
+		{
+			ScXmlStreamAttributes attrs = reader.scAttributes();
+
+			QString label = "";
+			if (attrs.hasAttribute("label"))
+				label = attrs.valueAsString("label");
+
+			MarkType type = MARKNoType;
+			if (attrs.hasAttribute("type"))
+				type = (MarkType) attrs.valueAsInt("type");
+
+			if (label != "" && type != MARKNoType)
+			{
+				Mark* mark = new Mark;
+				mark->label=attrs.valueAsString("label");
+				mark->setType(type);
+				doc->m_docMarksList.append(mark);
+
+				if (type == MARKVariableTextType && attrs.hasAttribute("str"))
+					mark->setString(attrs.valueAsString("str"));
+				if (type == MARK2ItemType && attrs.hasAttribute("ItemID"))
+				{
+					//QString itemName = attrs.valueAsString("itemName");
+					markeredItemsMap.insert(mark, attrs.valueAsInt("ItemID"));
+				}
+				if (type == MARK2MarkType && attrs.hasAttribute("MARKlabel"))
+				{
+					QString mark2Label = attrs.valueAsString("MARKlabel");
+					MarkType mark2Type = (MarkType) attrs.valueAsInt("MARKtype");
+					Mark* mark2 = doc->getMarkDefinied(mark2Label, mark2Type);
+					if (mark2 != NULL) //mark is not defined yet, insert into temp list for update to pointers later
+						mark->setMark(mark2);
+					else
+					{
+						QMap<QString, MarkType> mark2map;
+						mark2map.insert(mark2Label, mark2Type);
+						markeredMarksMap.insert(mark, mark2map);
+					}
+				}
+			}
+		}
+	}
+	return !reader.hasError();
+}
+
 bool Scribus150Format::readSections(ScribusDoc* doc, ScXmlStreamReader& reader)
 {
 	QStringRef tagName = reader.name();
@@ -3537,6 +3773,62 @@ bool Scribus150Format::readObject(ScribusDoc* doc, ScXmlStreamReader& reader, It
 				doc->Items = DItems;
 			}
 		}
+		if (tName == "MARK")
+		{
+			if (newItem->asTextFrame())
+			{
+				QString l = tAtt.valueAsString("label");
+				MarkType t = (MarkType) tAtt.valueAsInt("type");
+				Mark* mark = NULL;
+				if (m_Doc->isLoading())
+				{
+					mark = m_Doc->getMarkDefinied(l, t);
+				}
+				else
+				{	//doc is not loading so it is copy/paste task
+					if (t == MARKVariableTextType)
+						mark = m_Doc->getMarkDefinied(l, t);
+					else
+					{
+						//create copy of mark
+						Mark * oldMark = m_Doc->getMarkDefinied(l, t);
+						if (oldMark == NULL)
+						{
+							qWarning() << "wrong copy of oldMark";
+							mark = new Mark();
+							mark->setType(t);
+						}
+						else
+						{
+							mark = new Mark(*oldMark);
+							getUniqueName(l,doc->marksLabelsList(t), "_");
+						}
+						mark->label = l;
+						if (t == MARKNoteMasterType)
+						{  //create copy of note
+							TextNote* old = mark->getNotePtr();
+							TextNote* note = new TextNote(old->notesSet());
+							mark->setNotePtr(note);
+							note->setMasterMark(mark);
+							note->setSaxedText(old->saxedText());
+							m_Doc->m_docNotesList.append(note);
+							m_Doc->m_docMarksList.append(mark);
+							m_Doc->flag_notesChanged = true;
+						}
+					}
+				}
+				if (mark == NULL)
+					qDebug() << "Undefinied mark label ["<< l << "] type " << t;
+				else
+				{
+					//set pointer to item holds mark in his text
+					if (t == MARKAnchorType)
+						mark->setItemPtr(newItem);
+					mark->OwnPage = newItem->OwnPage;
+					newItem->itemText.insertMark(mark, newItem->itemText.length());
+				}
+			}
+		}
 		if (tName == "WeldEntry")
 		{
 			PageItem::weldingInfo wInf;
@@ -4004,6 +4296,7 @@ PageItem* Scribus150Format::pasteItem(ScribusDoc *doc, ScXmlStreamAttributes& at
 	bool isGroupFlag = attrs.valueAsBool("isGroupControl", 0);
 	if (isGroupFlag)
 		pt = PageItem::Group;
+	bool isNoteFrameFlag = attrs.valueAsBool("isNoteFrame", 0);
 	double xf, yf;
 	double x   = attrs.valueAsDouble("XPOS");
 	double y   = attrs.valueAsDouble("YPOS");
@@ -4126,7 +4419,7 @@ PageItem* Scribus150Format::pasteItem(ScribusDoc *doc, ScXmlStreamAttributes& at
 			currItem->OwnPage = pagenr;
 		break;
 	case PageItem::TextFrame:
-		z = doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor, true);
+		z = doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor, true, isNoteFrameFlag);
 		currItem = doc->Items->at(z);
 		if (pagenr > -2) 
 			currItem->OwnPage = pagenr;
@@ -5175,6 +5468,13 @@ bool Scribus150Format::loadPage(const QString & fileName, int pageNumber, bool M
 	WeldItems.clear();
 	WeldID.clear();
 
+	markeredItemsMap.clear();
+	markeredMarksMap.clear();
+	nsetRangeItemNamesMap.clear();
+	notesFramesData.clear();
+	notesMasterMarks.clear();
+	notesNSets.clear();
+
  	QString f(readSLA(fileName));
 	if (f.isEmpty())
 	{
@@ -5877,6 +6177,14 @@ bool Scribus150Format::readPageCount(const QString& fileName, int *num1, int *nu
 	QString pageName;
 	int counter = 0;
 	int counter2 = 0;
+
+	markeredItemsMap.clear();
+	markeredMarksMap.clear();
+	nsetRangeItemNamesMap.clear();
+	notesFramesData.clear();
+	notesMasterMarks.clear();
+	notesNSets.clear();
+
 	QString f(readSLA(fileName));
 	if (f.isEmpty())
 		return false;
@@ -5917,3 +6225,147 @@ bool Scribus150Format::readPageCount(const QString& fileName, int *num1, int *nu
 	*num2 = counter2;
 	return success;
 }
+
+void Scribus150Format::updateNames2Ptr() //after document load - items pointers should be updated
+{
+	if (!markeredItemsMap.isEmpty())
+	{
+		QMap<Mark*, int>::Iterator markIt;
+		QMap<Mark*, int>::Iterator end = markeredItemsMap.end();
+		for (markIt = markeredItemsMap.begin(); markIt != end; ++markIt)
+		{
+			Mark* mrk = markIt.key();
+			int ItemID = markIt.value();
+			if (LinkID.contains(ItemID))
+			{
+				mrk->setItemPtr(LinkID[ItemID]);
+				mrk->setString(QString("%1").arg(mrk->getItemPtr()->OwnPage +1));
+			}
+			else
+			{
+				qWarning() << "Scribus150Format::updateNames2Ptr() : wrong mark [" << mrk->label << "] data - item [" << ItemID << "] not exists - DELETING MARK";
+				if (!m_Doc->eraseMark(mrk, true))
+					qWarning() << "Erase mark [" << mrk->label << "] failed - was it definied?";
+			}
+		}
+		markeredItemsMap.clear();
+	}
+	if (!markeredMarksMap.isEmpty())
+	{
+		QMap<Mark*,QMap<QString, MarkType> >::iterator markIt;
+		QMap<Mark*,QMap<QString, MarkType> >::iterator end = markeredMarksMap.end();
+		for (markIt = markeredMarksMap.begin(); markIt != end; ++markIt)
+		{
+			Mark* mark = markIt.key();
+			QMap<QString, MarkType> mark2map = markIt.value();
+			QString label2 = mark2map.begin().key();
+			MarkType type2 = mark2map.begin().value();
+			Mark* mark2 = m_Doc->getMarkDefinied(label2, type2);
+			if (mark2 != NULL)
+			{
+				mark->setMark(mark2);
+			}
+			else
+			{
+				qWarning() << "Scribus150Format::updateNames2Ptr() : wrong mark [" << mark->label << "] data - pointed mark name [" << label2 << "] not exists - DELETING MARK";
+				if (!m_Doc->eraseMark(mark, true))
+					qWarning() << "Erase mark [" << mark->label << "] failed - was it definied?";
+
+			}
+		}
+		markeredMarksMap.clear();
+	}
+
+	//update endnotes frames pointers
+	if (!notesFramesData.isEmpty())
+	{
+		for (int i = 0; i < notesFramesData.count(); ++i)
+		{
+			NoteFrameData eF = notesFramesData.at(i);
+			NotesSet* NS = m_Doc->getNS(eF.NSname);
+			if (NS != NULL)
+			{
+				PageItem* item = LinkID.value(eF.myID);
+				if ((item != NULL) && item->isNoteFrame())
+				{
+					item->asNoteFrame()->setNS(NS);
+					if (NS->isEndNotes())
+					{
+						if (eF.NSrange == NSRdocument)
+							m_Doc->setEndNoteFrame(item->asNoteFrame(), (void*) NULL);
+						else if (eF.NSrange == NSRpage)
+							m_Doc->setEndNoteFrame(item->asNoteFrame(), (void*) m_Doc->DocPages.at(eF.index));
+						else if (eF.NSrange == NSRsection)
+							m_Doc->setEndNoteFrame(item->asNoteFrame(), m_Doc->getSectionKeyForPageIndex(eF.index));
+						else if (eF.NSrange == NSRstory)
+							m_Doc->setEndNoteFrame(item->asNoteFrame(), (void*) LinkID.value(eF.itemID));
+					}
+					else
+					{
+						PageItem* master = LinkID.value(eF.itemID);
+						item->asNoteFrame()->setMaster(master);
+						master->asTextFrame()->setNoteFrame(item->asNoteFrame());
+						//FIX welding with note frame
+						PageItem::weldingInfo wInf;
+						for (int i = 0 ; i < master->weldList.count(); i++)
+						{
+							wInf = master->weldList.at(i);
+							if (wInf.weldID == eF.myID)
+							{
+								master->weldList[i].weldItem = item;
+								break;
+							}
+						}
+					}
+				}
+				else
+					qDebug() << "Scribus150Format::updateNames2Ptr() : update end frames pointers - item is not note frame or name is wrong";
+			}
+		}
+	}
+	//update pointers to notes in master notes marks
+	if (!notesMasterMarks.isEmpty())
+	{
+		assert(!m_Doc->m_docMarksList.isEmpty() && !m_Doc->m_docNotesList.isEmpty());
+		QMap<QString, TextNote*>::Iterator it;
+		QMap<QString, TextNote*>::Iterator end = notesMasterMarks.end();
+		for (it = notesMasterMarks.begin(); it != end; ++it)
+		{
+			TextNote* note = it.value();
+			assert(note != NULL);
+			QString mrkLabel = it.key();
+			Mark* mrk = m_Doc->getMarkDefinied(mrkLabel, MARKNoteMasterType);
+			if (mrk == NULL)
+			{
+				qWarning() << "Scribus150Format::updateNames2Ptr() : cannot find master mark ("<<mrkLabel <<") for note - note will be deleted";
+				m_Doc->deleteNote(note, true);
+				continue;
+			}
+			note->setMasterMark(mrk);
+			mrk->setNotePtr(note);
+		}
+		notesMasterMarks.clear();
+	}
+	if (!notesNSets.isEmpty())
+	{
+		assert(!m_Doc->m_docNotesList.isEmpty());
+		QMap<TextNote*, QString>::Iterator it;
+		QMap<TextNote*, QString>::Iterator end = notesNSets.end();
+		for (it = notesNSets.begin(); it != end; ++it)
+		{
+			TextNote* note = it.key();
+			assert(note != NULL);
+			QString nsLabel = it.value();
+			NotesSet* ns = m_Doc->getNS(nsLabel);
+			if (ns != NULL)
+				note->setNotesSet(ns);
+			if (note->notesSet() == NULL)
+			{
+				qWarning() << "Scribus150Format::updateNames2Ptr()  : cannot find notes set ("<<nsLabel <<") for note - note will be deleted";
+				m_Doc->deleteNote(note, true);
+				continue;
+			}
+		}
+		notesNSets.clear();
+	}
+}
diff --git a/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h b/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h
index a77fc8f..0eefa91 100644
--- a/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h
+++ b/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h
@@ -9,6 +9,7 @@ for which a new license (GPL+exception) is in place.
 
 #include "pluginapi.h"
 #include "loadsaveplugin.h"
+#include "notesset.h"
 #include "scfonts.h"
 #include "scribusstructs.h"
 #include "styles/styleset.h"
@@ -125,6 +126,27 @@ class PLUGIN_API Scribus150Format : public LoadSavePlugin
 		bool readPrinterOptions(ScribusDoc* doc, ScXmlStreamReader& reader);
 		bool readSections(ScribusDoc* doc, ScXmlStreamReader& reader);
 		bool readTableOfContents(ScribusDoc* doc, ScXmlStreamReader& reader);
+		bool readNotes(ScribusDoc* doc, ScXmlStreamReader& reader);
+		bool readNotesSets(ScribusDoc* doc, ScXmlStreamReader& reader);
+		bool readNotesFrames(ScXmlStreamReader &reader);
+		bool readMarks(ScribusDoc* doc, ScXmlStreamReader& reader);
+
+		//lists of items and marks with names only, which need update to pointers
+		QMap<Mark*, int> markeredItemsMap;
+		QMap<Mark*, QMap<QString, MarkType> > markeredMarksMap;
+		QMap<QString, int> nsetRangeItemNamesMap;
+		QMap<QString, TextNote*> notesMasterMarks;
+		QMap<TextNote*, QString> notesNSets;
+		struct NoteFrameData {
+			QString NSname;
+			int myID;
+			int itemID;
+			int index;
+			NumerationRange NSrange;
+		};
+		QList<NoteFrameData> notesFramesData;
+		
+		void updateNames2Ptr(); //after document load items pointers should be updated in markeredItemList
 
 		PageItem* pasteItem(ScribusDoc *doc, ScXmlStreamAttributes& attrs, const QString& baseDir, int pagenr = -2 /* currentPage*/);
 
@@ -151,6 +173,10 @@ class PLUGIN_API Scribus150Format : public LoadSavePlugin
 		void writePdfOptions(ScXmlStreamWriter& docu);
 		void writeDocItemAttributes(ScXmlStreamWriter& docu);
 		void writeTOC(ScXmlStreamWriter& docu);
+		void writeMarks(ScXmlStreamWriter & docu);
+		void writeNotesSets(ScXmlStreamWriter & docu);
+		void writeNotesFrames(ScXmlStreamWriter & docu);
+		void writeNotes(ScXmlStreamWriter & docu);
 		void writePageSets(ScXmlStreamWriter& docu);
 		void writeSections(ScXmlStreamWriter& docu);
 		void writePatterns(ScXmlStreamWriter& docu, const QString& baseDir, bool part = false, Selection* selection = 0);
diff --git a/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp b/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
index 5b35591..8a68530 100644
--- a/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
+++ b/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
@@ -20,6 +20,7 @@ for which a new license (GPL+exception) is in place.
 #include "scribusdoc.h"
 #include "scribusview.h"
 #include "hyphenator.h"
+#include "notesset.h"
 #include "pageitem_latexframe.h"
 #ifdef HAVE_OSG
 	#include "pageitem_osgframe.h"
@@ -28,6 +29,7 @@ for which a new license (GPL+exception) is in place.
 #include "pageitem_arc.h"
 #include "pageitem_spiral.h"
 #include "pageitem_table.h"
+#include "pageitem_noteframe.h"
 
 #include "units.h"
 #include "util.h"
@@ -71,6 +73,9 @@ QString Scribus150Format::saveElements(double xp, double yp, double wp, double h
 		emG.append(currItem);
 		if ((currItem->asTextFrame()) || (currItem->asPathText()))
 		{
+			//for notes frames text should not be saved
+			if (currItem->isNoteFrame())
+				continue;
 			for (int e = currItem->firstInFrame(); e <= currItem->lastInFrame(); ++e)
 			{
 				uint chr = currItem->itemText.text(e).unicode();
@@ -389,6 +394,10 @@ bool Scribus150Format::saveFile(const QString & fileName, const FileFormat & /*
 	writePdfOptions(docu);
 	writeDocItemAttributes(docu);
 	writeTOC(docu);
+	writeMarks(docu);
+	writeNotesSets(docu);
+	writeNotesFrames(docu);
+	writeNotes(docu);
 	writePageSets(docu);
 	writeSections(docu);
 	writePatterns(docu, fileDir);
@@ -1191,6 +1200,9 @@ void Scribus150Format::writeSections(ScXmlStreamWriter & docu)
 			case Type_A_B_C:
 				docu.writeAttribute("Type", "Type_A_B_C");
 				break;
+			case Type_asterix:
+				docu.writeAttribute("Type", "Type_asterix");
+				break;
 			case Type_None:
 				docu.writeAttribute("Type", "Type_None");
 				break;
@@ -1204,6 +1216,154 @@ void Scribus150Format::writeSections(ScXmlStreamWriter & docu)
 	docu.writeEndElement();
 }
 
+void Scribus150Format::writeMarks(ScXmlStreamWriter & docu)
+{
+	//write list of definied marks to SLA
+	if (m_Doc->m_docMarksList.isEmpty())
+		return;
+	docu.writeStartElement("Marks");
+	foreach(Mark* mrk,  m_Doc->m_docMarksList)
+	{
+		if (mrk->isType(MARKNoteFrameType))
+			continue;
+		docu.writeEmptyElement("Mark");
+		docu.writeAttribute("label", mrk->label);
+		docu.writeAttribute("type", mrk->getType());
+		if (mrk->isType(MARK2ItemType) && mrk->hasItemPtr())
+		{
+			const PageItem* item = mrk->getItemPtr();
+			assert(item != NULL);
+			docu.writeAttribute("ItemID", qHash(item));
+			//docu.writeAttribute("itemName", item->itemName());
+		}
+		else if (mrk->isType(MARKVariableTextType) && mrk->hasString())
+			docu.writeAttribute("str", mrk->getString());
+		else if (mrk->isType(MARK2MarkType) && mrk->hasMark())
+		{
+			QString label;
+			MarkType type;
+			mrk->getMark(label, type);
+			docu.writeAttribute("MARKlabel", label);
+			docu.writeAttribute("MARKtype", type);
+		}
+	}
+	docu.writeEndElement();
+}
+
+void Scribus150Format::writeNotesSets(ScXmlStreamWriter & docu)
+{
+	//write notes sets
+	docu.writeStartElement("NotesSets");
+	QList<NotesSet*>::Iterator itNS;
+	QList<NotesSet*>::Iterator end = m_Doc->m_docNotesSetsList.end();
+	for (itNS = m_Doc->m_docNotesSetsList.begin(); itNS != end; ++itNS)
+	{
+		NotesSet* NS = (*itNS);
+		docu.writeEmptyElement("notesSet");
+		docu.writeAttribute("Name", NS->name());
+		docu.writeAttribute("Start", NS->start());
+		docu.writeAttribute("Endnotes", NS->isEndNotes());
+		switch (NS->getType())
+		{
+			case Type_1_2_3:
+				docu.writeAttribute("Type", "Type_1_2_3");
+				break;
+			case Type_i_ii_iii:
+				docu.writeAttribute("Type", "Type_i_ii_iii");
+				break;
+			case Type_I_II_III:
+				docu.writeAttribute("Type", "Type_I_II_III");
+				break;
+			case Type_a_b_c:
+				docu.writeAttribute("Type", "Type_a_b_c");
+				break;
+			case Type_A_B_C:
+				docu.writeAttribute("Type", "Type_A_B_C");
+				break;
+			case Type_asterix:
+				docu.writeAttribute("Type", "Type_asterix");
+				break;
+			case Type_None:
+				docu.writeAttribute("Type", "Type_None");
+				break;
+		}
+		docu.writeAttribute("Range", (int) NS->range());
+		docu.writeAttribute("Prefix", NS->prefix());
+		docu.writeAttribute("Suffix", NS->suffix());
+		docu.writeAttribute("AutoHeight", NS->isAutoNotesHeight());
+		docu.writeAttribute("AutoWidth", NS->isAutoNotesWidth());
+		docu.writeAttribute("AutoRemove", NS->isAutoRemoveEmptyNotesFrames());
+		docu.writeAttribute("AutoWeld", NS->isAutoWeldNotesFrames());
+		docu.writeAttribute("SuperNote", NS->isSuperscriptInNote());
+		docu.writeAttribute("SuperMaster", NS->isSuperscriptInMaster());
+		docu.writeAttribute("MarksStyle", NS->marksChStyle());
+		docu.writeAttribute("NotesStyle", NS->notesParStyle());
+	}
+	docu.writeEndElement();
+}
+
+void Scribus150Format::writeNotesFrames(ScXmlStreamWriter &docu)
+{
+	docu.writeStartElement("NotesFrames");
+
+	QList<PageItem_NoteFrame*> NFList;
+	foreach (NotesSet* NS, m_Doc->m_docNotesSetsList)
+		NFList.append(m_Doc->listNotesFrames(NS));
+
+	for (int it = 0; it < NFList.count(); ++it)
+	{
+		PageItem_NoteFrame* nF = NFList.at(it);
+		NotesSet* NS = nF->notesSet();
+		if (NS->isEndNotes())
+		{
+			docu.writeEmptyElement("ENDNOTEFRAME");
+			docu.writeAttribute("NSname", NS->name());
+			docu.writeAttribute("range", (int) NS->range());
+			docu.writeAttribute("myID", qHash(nF));
+			//docu.writeAttribute("name", nF->itemName());
+			
+			rangeItem rI = m_Doc->m_docEndNotesFramesMap.value(nF);
+			if (NS->range() == NSRsection)
+				docu.writeAttribute("index", rI.sectionIndex);
+			else if (NS->range() == NSRpage)
+				docu.writeAttribute("index", rI.page->pageNr());
+			else if (NS->range() == NSRstory)
+				docu.writeAttribute("ItemID", qHash(rI.firstStoryFrame));
+				//docu.writeAttribute("item", rI.firstStoryFrame->itemName());
+		}
+		else //footnotes frame
+		{
+			docu.writeEmptyElement("FOOTNOTEFRAME");
+			docu.writeAttribute("NSname", NS->name());
+			docu.writeAttribute("myID", qHash(nF));
+			//docu.writeAttribute("name", nF->itemName());
+			docu.writeAttribute("MasterID", qHash(nF->masterFrame()));
+			//docu.writeAttribute("master",nF->masterFrame()->itemName());
+		}
+	}
+	docu.writeEndElement();
+}
+
+void Scribus150Format::writeNotes(ScXmlStreamWriter & docu)
+{
+	//write notes
+	if (m_Doc->m_docNotesList.isEmpty())
+		return;
+	docu.writeStartElement("Notes");
+	QList<TextNote*>::iterator itTN;
+	QList<TextNote*>::iterator end = m_Doc->m_docNotesList.end();
+	for (itTN = m_Doc->m_docNotesList.begin(); itTN != end; ++itTN)
+	{
+		TextNote* TN = (*itTN);
+		if (TN->masterMark() == NULL)
+			continue;
+		docu.writeEmptyElement("Note");
+		docu.writeAttribute("Master", TN->masterMark()->label);
+		docu.writeAttribute("NSet", TN->notesSet()->name());
+		docu.writeAttribute("Text", TN->saxedText());
+	}
+	docu.writeEndElement();
+}
 
 void Scribus150Format::writePageSets(ScXmlStreamWriter & docu) 
 {	
@@ -1353,7 +1513,10 @@ void Scribus150Format::writeITEXTs(ScribusDoc *doc, ScXmlStreamWriter &docu, Pag
 	CharStyle lastStyle;
 	int lastPos = 0;
 	QString tmpnum;
-	for(int k = 0; k < item->itemText.length(); ++k)
+	int iTLen = item->itemText.length();
+	if (item->isNoteFrame())
+		iTLen = 0;  //used for saving empty endnotes frames, as they will be filled automatically
+	for(int k = 0; k < iTLen; ++k)
 	{
 		const CharStyle& style1(item->itemText.charStyle(k));
 		const QChar ch = item->itemText.text(k);
@@ -1401,6 +1564,13 @@ void Scribus150Format::writeITEXTs(ScribusDoc *doc, ScXmlStreamWriter &docu, Pag
 			docu.writeAttribute("Unicode", tmpnum);
 			docu.writeAttribute("COBJ", item->itemText.object(k)->inlineCharID);
 		}
+		else if (ch == SpecialChars::OBJECT && item->itemText.item(k)->mark != NULL)
+		{
+			Mark* mark = item->itemText.item(k)->mark;
+			docu.writeEmptyElement("MARK");
+			docu.writeAttribute("label", mark->label);
+			docu.writeAttribute("type", mark->getType());
+		}
 		else if (ch == SpecialChars::PARSEP)	// stores also the paragraphstyle for preceding chars
 			putPStyle(docu, item->itemText.paragraphStyle(k), "para");
 		else if (ch == SpecialChars::TAB)
@@ -1451,19 +1621,19 @@ void Scribus150Format::writeITEXTs(ScribusDoc *doc, ScXmlStreamWriter &docu, Pag
 		lastPos = k + 1;
 	}
 	// write pending chars
-	if ( item->itemText.length() - lastPos > 0)
+	if ( iTLen - lastPos > 0)
 	{
 		docu.writeEmptyElement("ITEXT");
 		/*if (item->asPathText())
 			putCStylePT(docu, lastStyle);
 		else*/
 			putCStyle(docu, lastStyle);
-		docu.writeAttribute("CH", textWithSoftHyphens(item->itemText, lastPos, item->itemText.length()));
+		docu.writeAttribute("CH", textWithSoftHyphens(item->itemText, lastPos, iTLen));
 	}
 	// paragraphstyle for trailing chars
-	if (item->itemText.length() == 0 || item->itemText.text(item->itemText.length()-1) != SpecialChars::PARSEP)
+	if (iTLen == 0 || item->itemText.text(iTLen-1) != SpecialChars::PARSEP)
 	{
-		putPStyle(docu, item->itemText.paragraphStyle(item->itemText.length()), "trail");
+		putPStyle(docu, item->itemText.paragraphStyle(iTLen), "trail");
 	}
 }
 
@@ -1714,7 +1884,10 @@ void Scribus150Format::WriteObjects(ScribusDoc *doc, ScXmlStreamWriter& docu, co
 			else
 			{
 				docu.writeAttribute("BACKITEM", -1);
-				writeITEXTs(doc, docu, item);
+				if (item->isNoteFrame())
+					docu.writeAttribute("isNoteFrame", 1);
+				else
+					writeITEXTs(doc, docu, item);
 			}
 		}
 
diff --git a/Scribus/scribus/plugins/import/ps/import.prolog b/Scribus/scribus/plugins/import/ps/import.prolog
index 6e656d2..a6b9015 100644
--- a/Scribus/scribus/plugins/import/ps/import.prolog
+++ b/Scribus/scribus/plugins/import/ps/import.prolog
@@ -928,7 +928,11 @@ currentpagedevice /HWResolution get aload pop
 % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
 % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
 
+<<<<<<< HEAD
+% $Id: import.prolog 13454 2009-05-08 19:04:32Z jghali $
+=======
 % $Id$
+>>>>>>> bea5ac5c4844d7b78798edca794c0a7bf0155c96
 % traceimg.ps
 % Trace the data supplied to the 'image' operator.
 
diff --git a/Scribus/scribus/plugins/saveastemplateplugin/satdialog.cpp b/Scribus/scribus/plugins/saveastemplateplugin/satdialog.cpp
index b03e4fc..f81f125 100644
--- a/Scribus/scribus/plugins/saveastemplateplugin/satdialog.cpp
+++ b/Scribus/scribus/plugins/saveastemplateplugin/satdialog.cpp
@@ -36,7 +36,7 @@ public:
 	};
 };
 
-SATDialog::SATDialog(QWidget* parent, QString tmplName, int pageW, int pageH) : QDialog(parent)
+satdialog::satdialog(QWidget* parent, QString tmplName, int pageW, int pageH) : QDialog(parent)
 {
 	setupUi(this);
 	setModal(true);
@@ -54,7 +54,7 @@ SATDialog::SATDialog(QWidget* parent, QString tmplName, int pageW, int pageH) :
 	connect(detailButton, SIGNAL(stateChanged(int)), this, SLOT(detailClicked(int)));
 }
 
-void SATDialog::detailClicked(int state)
+void satdialog::detailClicked(int state)
 {
 	isFullDetail = state == Qt::Checked;
 
@@ -74,7 +74,7 @@ void SATDialog::detailClicked(int state)
 	emailEdit->setVisible(isFullDetail);
 }
 
-void SATDialog::readPrefs()
+void satdialog::readPrefs()
 {
 	prefs = PrefsManager::instance()->prefsFile->getPluginContext("satemplate");
 	author = prefs->get("author", "");
@@ -84,14 +84,14 @@ void SATDialog::readPrefs()
 	detailButton->setCheckState(isFullDetail ? Qt::Checked : Qt::Unchecked);
 }
 
-void SATDialog::writePrefs()
+void satdialog::writePrefs()
 {
 	prefs->set("author", authorEdit->text());
 	prefs->set("email", emailEdit->text());
 	prefs->set("isFullDetail", isFullDetail);
 }
 
-QString SATDialog::findTemplateXml(QString dir)
+QString satdialog::findTemplateXml(QString dir)
 {
 	QString lang = ScCore->getGuiLanguage();
 	QString tmp = dir + "/template." + lang + ".xml";
@@ -107,7 +107,7 @@ QString SATDialog::findTemplateXml(QString dir)
 	return dir + "/template.xml";	
 }
 
-void SATDialog::addCategories(const QString& dir)
+void satdialog::addCategories(const QString& dir)
 {
 	// Read categories from the dir itself
 	QString tmplFile = findTemplateXml(dir);
@@ -129,7 +129,7 @@ void SATDialog::addCategories(const QString& dir)
 	}
 }
 
-void SATDialog::readCategories(const QString& fileName)
+void satdialog::readCategories(const QString& fileName)
 {
 	QFile file(fileName);
 	CategoriesReader catReader;
@@ -146,7 +146,7 @@ void SATDialog::readCategories(const QString& fileName)
 	}
 }
 
-void SATDialog::setupCategories()
+void satdialog::setupCategories() 
 {
 	// en will be used in template.xml and it will be then replaced with the lang when used for users
 	// to get the categories in their language.
@@ -194,7 +194,7 @@ void SATDialog::setupCategories()
 	catsCombo->setEditable(true);
 }
 
-void SATDialog::setupPageSize(int w, int h)
+void satdialog::setupPageSize(int w, int h)
 {
 	QString sizelist[] = 
 		{"2380x3368", "1684x2380", "1190x1684", "842x1190", "595x842", "421x595", "297x421", "210x297", "148x210",
@@ -240,7 +240,7 @@ void SATDialog::setupPageSize(int w, int h)
 	psizeEdit->setText(psize + orient);
 }
 
-SATDialog::~SATDialog()
+satdialog::~satdialog()
 {
 	writePrefs();
 }
diff --git a/Scribus/scribus/plugins/saveastemplateplugin/satdialog.h b/Scribus/scribus/plugins/saveastemplateplugin/satdialog.h
index e14cd9a..b0936ad 100644
--- a/Scribus/scribus/plugins/saveastemplateplugin/satdialog.h
+++ b/Scribus/scribus/plugins/saveastemplateplugin/satdialog.h
@@ -14,13 +14,13 @@ for which a new license (GPL+exception) is in place.
 #include <QMap>
 #include <prefscontext.h>
 
-class SATDialog : public QDialog, public Ui::SATDialogBase
+class satdialog : public QDialog, public Ui::satdialog
 {
 	Q_OBJECT
 
 public:
-	SATDialog(QWidget* parent, QString tmplName = "", int pageW = 0, int pageH = 0);
-	~SATDialog();
+	satdialog(QWidget* parent, QString tmplName = "", int pageW = 0, int pageH = 0);
+	~satdialog();
 
 	QMap<QString, QString> cats;
 private slots:
diff --git a/Scribus/scribus/plugins/saveastemplateplugin/satdialog.ui b/Scribus/scribus/plugins/saveastemplateplugin/satdialog.ui
index 731f754..7d28438 100644
--- a/Scribus/scribus/plugins/saveastemplateplugin/satdialog.ui
+++ b/Scribus/scribus/plugins/saveastemplateplugin/satdialog.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0">
- <class>SATDialogBase</class>
- <widget class="QDialog" name="SATDialogBase">
+ <class>satdialog</class>
+ <widget class="QDialog" name="satdialog">
   <property name="geometry">
    <rect>
     <x>0</x>
@@ -17,7 +17,7 @@
    <item row="0" column="0">
     <widget class="QLabel" name="label">
      <property name="text">
-      <string>Name:</string>
+      <string>Name</string>
      </property>
     </widget>
    </item>
@@ -41,7 +41,7 @@
    <item row="2" column="0">
     <widget class="QLabel" name="catsLabel">
      <property name="text">
-      <string>Category:</string>
+      <string>Category</string>
      </property>
     </widget>
    </item>
@@ -55,7 +55,7 @@
    <item row="3" column="0">
     <widget class="QLabel" name="psizeLabel">
      <property name="text">
-      <string>Page Size:</string>
+      <string>Page Size</string>
      </property>
     </widget>
    </item>
@@ -69,7 +69,7 @@
    <item row="4" column="0">
     <widget class="QLabel" name="colorsLabel">
      <property name="text">
-      <string>Colors:</string>
+      <string>Colors</string>
      </property>
     </widget>
    </item>
@@ -83,7 +83,7 @@
    <item row="5" column="0">
     <widget class="QLabel" name="descrLabel">
      <property name="text">
-      <string>Description:</string>
+      <string>Description</string>
      </property>
     </widget>
    </item>
@@ -103,7 +103,7 @@
    <item row="6" column="0">
     <widget class="QLabel" name="usageLabel">
      <property name="text">
-      <string>Usage:</string>
+      <string>Usage</string>
      </property>
     </widget>
    </item>
@@ -123,7 +123,7 @@
    <item row="7" column="0">
     <widget class="QLabel" name="authorLabel">
      <property name="text">
-      <string>Author:</string>
+      <string>Author</string>
      </property>
     </widget>
    </item>
@@ -137,7 +137,7 @@
    <item row="8" column="0">
     <widget class="QLabel" name="emailLabel">
      <property name="text">
-      <string>Email:</string>
+      <string>Email</string>
      </property>
     </widget>
    </item>
@@ -165,7 +165,7 @@
   <connection>
    <sender>buttonBox</sender>
    <signal>accepted()</signal>
-   <receiver>SATDialogBase</receiver>
+   <receiver>satdialog</receiver>
    <slot>accept()</slot>
    <hints>
     <hint type="sourcelabel">
@@ -181,7 +181,7 @@
   <connection>
    <sender>buttonBox</sender>
    <signal>rejected()</signal>
-   <receiver>SATDialogBase</receiver>
+   <receiver>satdialog</receiver>
    <slot>reject()</slot>
    <hints>
     <hint type="sourcelabel">
diff --git a/Scribus/scribus/plugins/saveastemplateplugin/satemplate.cpp b/Scribus/scribus/plugins/saveastemplateplugin/satemplate.cpp
index 7ec9a3f..7d97eb4 100644
--- a/Scribus/scribus/plugins/saveastemplateplugin/satemplate.cpp
+++ b/Scribus/scribus/plugins/saveastemplateplugin/satemplate.cpp
@@ -56,7 +56,7 @@ void SaveAsTemplatePlugin::languageChange()
 	m_actionInfo.keySequence = "Ctrl+Alt+S";
 	// Menu
 	m_actionInfo.menu = "File";
-	m_actionInfo.menuAfterName = "fileSaveAs";
+	m_actionInfo.menuAfterName = "SaveAs";
 	m_actionInfo.enabledOnStartup = true;
 	m_actionInfo.needsNumObjects = -1;
 }
@@ -145,7 +145,7 @@ void MenuSAT::RunSATPlug(ScribusDoc* doc)
 
 	if (currentFile !=  doc->DocName)
 	{
-		SATDialog* satdia = new SATDialog(doc->scMW(),docName,
+		satdialog* satdia = new satdialog(doc->scMW(),docName,
 										  static_cast<int>(doc->pageWidth() + 0.5),
 										  static_cast<int>(doc->pageHeight() + 0.5));
 		if (satdia->exec())
@@ -171,7 +171,7 @@ void MenuSAT::RunSATPlug(ScribusDoc* doc)
 
 // --------------------- CLASS sat ------------------------------------------------//
 
-sat::sat(ScribusDoc* doc, SATDialog* satdia, QString fileName, QString tmplDir)
+sat::sat(ScribusDoc* doc, satdialog* satdia, QString fileName, QString tmplDir)
 {
 	lang = ScCore->getGuiLanguage();
 	m_Doc = doc;
diff --git a/Scribus/scribus/plugins/saveastemplateplugin/satemplate.h b/Scribus/scribus/plugins/saveastemplateplugin/satemplate.h
index 1fde246..ca62e9c 100644
--- a/Scribus/scribus/plugins/saveastemplateplugin/satemplate.h
+++ b/Scribus/scribus/plugins/saveastemplateplugin/satemplate.h
@@ -10,7 +10,6 @@ for which a new license (GPL+exception) is in place.
 #include "pluginapi.h"
 #include "scplugin.h"
 
-class ScribusDoc;
 
 class PLUGIN_API SaveAsTemplatePlugin : public ScActionPlugin
 {
@@ -35,7 +34,7 @@ extern "C" PLUGIN_API ScPlugin* saveastemplateplugin_getPlugin();
 extern "C" PLUGIN_API void saveastemplateplugin_freePlugin(ScPlugin* plugin);
 
 
-class SATDialog;
+class satdialog;
 
 
 class MenuSAT : public QObject
@@ -56,7 +55,7 @@ class sat
 {
 private:
 	ScribusDoc* m_Doc;
-	SATDialog* dia;
+	satdialog* dia;
 	QString file;
 	QString dir;
 	QString tmplXmlFile;
@@ -68,7 +67,7 @@ private:
 public:
 	void createTmplXml();
 	void createImages();
-	sat(ScribusDoc* doc, SATDialog* satdia, QString fileName, QString tmplDir);
+	sat(ScribusDoc* doc, satdialog* satdia, QString fileName, QString tmplDir);
 	~sat();
 };
 
diff --git a/Scribus/scribus/plugins/scripter/CMakeLists.txt b/Scribus/scribus/plugins/scripter/CMakeLists.txt
index 59f1800..22f0cae 100644
--- a/Scribus/scribus/plugins/scripter/CMakeLists.txt
+++ b/Scribus/scribus/plugins/scripter/CMakeLists.txt
@@ -85,5 +85,8 @@ FILE(GLOB sceditor "python/sceditor/*.zip" "python/sceditor/*.png" "python/scedi
 INSTALL(FILES ${sceditor}
   DESTINATION ${PLUGINDIR}/scripter/sceditor
 )
+<<<<<<< HEAD
+=======
 
 ADD_DEPENDENCIES(${SCRIBUS_SCRIPTER_PLUGIN} ${EXE_NAME})
+>>>>>>> bea5ac5c4844d7b78798edca794c0a7bf0155c96
diff --git a/Scribus/scribus/plugins/scripter/python/autoload/about.spy b/Scribus/scribus/plugins/scripter/python/autoload/about.spy
new file mode 100644
index 0000000..4c7406f
--- /dev/null
+++ b/Scribus/scribus/plugins/scripter/python/autoload/about.spy
@@ -0,0 +1,3 @@
+## title = About
+
+Scripter.aboutScripter()
diff --git a/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp b/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
index 5d44770..30b2583 100644
--- a/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
+++ b/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
@@ -18,6 +18,8 @@ for which a new license (GPL+exception) is in place.
 
 #include "runscriptdialog.h"
 #include "ui/helpbrowser.h"
+#include "ui/marksmanager.h"
+#include "ui/notessetmanager.h"
 #include "ui/propertiespalette.h" //TODO Move the calls to this to a signal
 #include "ui/pagepalette.h" //TODO Move the calls to this to a signal
 #include "ui/layers.h" //TODO Move the calls to this to a signal
@@ -151,6 +153,8 @@ void ScripterCore::FinishScriptRun()
 	if (ScMW->HaveDoc)
 	{
 		ScMW->propertiesPalette->setDoc(ScMW->doc);
+		ScMW->marksManager->setDoc(ScMW->doc);
+		ScMW->nsManager->setDoc(ScMW->doc);
 		ScMW->layerPalette->setDoc(ScMW->doc);
 		ScMW->outlinePalette->setDoc(ScMW->doc);
 		ScMW->outlinePalette->BuildTree();
diff --git a/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp b/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
index 7f90425..536abe2 100644
--- a/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
+++ b/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
@@ -32,7 +32,15 @@ for which a new license (GPL+exception) is in place.
 HunspellPluginImpl::HunspellPluginImpl() : QObject(0)
 {
 	//hspellers=NULL;
+<<<<<<< HEAD
+<<<<<<< HEAD
+	numDicts=0;
+=======
 //	numDicts=0;
+>>>>>>> a78f1676d3bfe54774d2c739bf39fefd86135f16
+=======
+//	numDicts=0;
+>>>>>>> bea5ac5c4844d7b78798edca794c0a7bf0155c96
 	m_runningForSE=false;
 	m_SE=NULL;
 }
@@ -45,7 +53,15 @@ HunspellPluginImpl::~HunspellPluginImpl()
 		h = NULL;
 	}
 	hspellerMap.clear();
+<<<<<<< HEAD
+<<<<<<< HEAD
+	numDicts = 0;
+=======
+//	numDicts = 0;
+>>>>>>> a78f1676d3bfe54774d2c739bf39fefd86135f16
+=======
 //	numDicts = 0;
+>>>>>>> bea5ac5c4844d7b78798edca794c0a7bf0155c96
 }
 
 bool HunspellPluginImpl::run(const QString & target, ScribusDoc* doc)
@@ -62,17 +78,69 @@ bool HunspellPluginImpl::run(const QString & target, ScribusDoc* doc)
 	return spellCheckOk;
 }
 
+<<<<<<< HEAD
+<<<<<<< HEAD
+bool HunspellPluginImpl::findDictionaries()
+{
+	dictionaryPaths=ScPaths::instance().spellDirs();
+	if (dictionaryPaths.count()==0)
+		return false;
+	return true;
+}
+
+bool HunspellPluginImpl::initHunspell()
+{
+	bool dictPathFound=findDictionaries();
+=======
+bool HunspellPluginImpl::initHunspell()
+{
+	bool dictPathFound=LanguageManager::instance()->findDictionaries(dictionaryPaths);
+>>>>>>> a78f1676d3bfe54774d2c739bf39fefd86135f16
+=======
 bool HunspellPluginImpl::initHunspell()
 {
 	bool dictPathFound=LanguageManager::instance()->findDictionaries(dictionaryPaths);
+>>>>>>> bea5ac5c4844d7b78798edca794c0a7bf0155c96
 	if (!dictPathFound)
 	{
 		qDebug()<<"No preinstalled dictonary paths found";
 		return false;
 	}
+<<<<<<< HEAD
+<<<<<<< HEAD
+	for (int i=0; i<dictionaryPaths.count(); ++i)
+	{
+		// Find the dic and aff files in the location
+		QDir dictLocation(dictionaryPaths.at(i));
+		QStringList dictFilters("*.dic");
+		QStringList dictList(dictLocation.entryList(dictFilters, QDir::Files, QDir::Name));
+		dictList.replaceInStrings(".dic","");
+
+		//Ensure we have aff+dic file pairs, remove any hyphenation dictionaries from the list
+		QString dictName;
+		foreach(dictName, dictList)
+		{
+			if (!QFile::exists(dictionaryPaths.at(i)+dictName+".aff"))
+				dictList.removeAll(dictName);
+			else
+			{
+				if (!dictionaryMap.contains(dictName))
+					dictionaryMap.insert(dictName, dictionaryPaths.at(i)+dictName);
+			}
+		}
+		qDebug()<<"Number of dictionaries/AFFs found in"<<dictionaryPaths.at(i)<<":"<<dictList.count();
+	}
+	numDicts=dictionaryMap.count();
+=======
+	dictionaryMap.clear();
+	LanguageManager::instance()->findDictionarySets(dictionaryPaths, dictionaryMap);
+//	numDicts=dictionaryMap.count();
+>>>>>>> a78f1676d3bfe54774d2c739bf39fefd86135f16
+=======
 	dictionaryMap.clear();
 	LanguageManager::instance()->findDictionarySets(dictionaryPaths, dictionaryMap);
 //	numDicts=dictionaryMap.count();
+>>>>>>> bea5ac5c4844d7b78798edca794c0a7bf0155c96
 	if (dictionaryMap.count()==0)
 		return false;
 
@@ -122,6 +190,13 @@ bool HunspellPluginImpl::parseTextFrame(StoryText *iText)
 		currPos=wordStart;
 		QString word=iText->text(wordStart,wordEnd-wordStart);
 		QString wordLang=iText->charStyle(wordStart).language();
+<<<<<<< HEAD
+<<<<<<< HEAD
+		//qDebug()<<word<<wordLang;
+=======
+>>>>>>> a78f1676d3bfe54774d2c739bf39fefd86135f16
+=======
+>>>>>>> bea5ac5c4844d7b78798edca794c0a7bf0155c96
 		wordLang=LanguageManager::instance()->getAbbrevFromLang(wordLang, true, false);
 		//A little hack as for some reason our en dictionary from the aspell plugin was not called en_GB or en_US but en, content was en_GB though. Meh.
 		if (wordLang=="en")
diff --git a/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h b/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h
index 3048636..6f231a2 100644
--- a/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h
+++ b/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h
@@ -30,6 +30,13 @@ class HunspellPluginImpl : public QObject
 		HunspellPluginImpl();
 		~HunspellPluginImpl();
 		bool run(const QString & target, ScribusDoc* doc=0);
+<<<<<<< HEAD
+<<<<<<< HEAD
+		bool findDictionaries();
+=======
+>>>>>>> a78f1676d3bfe54774d2c739bf39fefd86135f16
+=======
+>>>>>>> bea5ac5c4844d7b78798edca794c0a7bf0155c96
 		bool initHunspell();
 		bool checkWithHunspell();
 		bool checkWithHunspellSE();
@@ -42,7 +49,15 @@ class HunspellPluginImpl : public QObject
 	protected:
 		QMap<QString, QString> dictionaryMap;
 		QStringList dictionaryPaths;
+<<<<<<< HEAD
+<<<<<<< HEAD
+		int numDicts, numAFFs;
+=======
 		//int numDicts, numAFFs;
+>>>>>>> a78f1676d3bfe54774d2c739bf39fefd86135f16
+=======
+		//int numDicts, numAFFs;
+>>>>>>> bea5ac5c4844d7b78798edca794c0a7bf0155c96
 		QMap<QString, Hunspell*> hspellerMap;
 		ScribusDoc* m_doc;
 		bool m_runningForSE;
diff --git a/Scribus/scribus/rc4.c b/Scribus/scribus/rc4.c
index ddeaccf..5358107 100644
--- a/Scribus/scribus/rc4.c
+++ b/Scribus/scribus/rc4.c
@@ -139,5 +139,5 @@ rc4_encrypt(rc4_context_t       *text,		/* I - Context */
 
 
 /*
- * End of "$Id$".
+ * End of "$Id: rc4.c 485 2004-10-20 21:05:49Z fschmid $".
  */
diff --git a/Scribus/scribus/scribus.cpp b/Scribus/scribus/scribus.cpp
index 8bd7a5d..5f3bd3a 100644
--- a/Scribus/scribus/scribus.cpp
+++ b/Scribus/scribus/scribus.cpp
@@ -99,11 +99,14 @@ for which a new license (GPL+exception) is in place.
 #include "gtgettext.h"
 #include "hyphenator.h"
 #include "langmgr.h"
+#include "marks.h"
+#include "notesset.h"
 #include "pageitem_group.h"
 #include "pageitem_imageframe.h"
 #include "pageitem_latexframe.h"
 #include "pageitem_table.h"
 #include "pageitem_textframe.h"
+#include "pageitem_noteframe.h"
 #include "pagesize.h"
 #include "pdflib.h"
 #include "pdfoptions.h"
@@ -163,6 +166,14 @@ for which a new license (GPL+exception) is in place.
 #include "ui/loremipsum.h"
 #include "ui/marginwidget.h"
 #include "ui/margindialog.h"
+#include "ui/mark2item.h"
+#include "ui/mark2mark.h"
+#include "ui/markanchor.h"
+#include "ui/marknote.h"
+#include "ui/markvariabletext.h"
+#include "ui/MarkInsertDlg.h"
+#include "ui/marksmanager.h"
+#include "ui/masterpagepalette.h"
 #include "ui/mergedoc.h"
 #include "ui/movepage.h"
 #include "ui/multipleduplicate.h"
@@ -173,6 +184,7 @@ for which a new license (GPL+exception) is in place.
 #include "ui_nftdialog.h"
 #include "ui/nftwidget.h"
 #include "ui/nodeeditpalette.h"
+#include "ui/notessetmanager.h"
 #ifdef HAVE_OSG
 	#include "ui/osgeditor.h"
 #endif
@@ -589,6 +601,17 @@ void ScribusMainWindow::initPalettes()
 	connect( styleManager, SIGNAL(paletteShown(bool)), scrActions["editStyles"], SLOT(setChecked(bool)));
 	styleManager->installEventFilter(this);
 
+	// initializing mark`s manager
+	marksManager = new MarksManager(this, "marksManager");
+	connect( scrActions["editMarks"], SIGNAL(toggled(bool)), marksManager, SLOT(setPaletteShown(bool)) );
+	connect( marksManager, SIGNAL(paletteShown(bool)), scrActions["editMarks"], SLOT(setChecked(bool)));
+	marksManager->installEventFilter(this);
+	// initializing notes set`s manager
+	nsManager = new NotesSetsManager(this, "notessetsManager");
+	connect( scrActions["editNotesSets"], SIGNAL(toggled(bool)), nsManager, SLOT(setPaletteShown(bool)) );
+	connect( nsManager, SIGNAL(paletteShown(bool)), scrActions["editNotesSets"], SLOT(setChecked(bool)));
+	nsManager->installEventFilter(this);
+
 //	connect(docCheckerPalette, SIGNAL(selectElement(int, int)), this, SLOT(selectItemsFromOutlines(int, int)));
 	connect(docCheckerPalette, SIGNAL(selectElementByItem(PageItem *, bool)), this, SLOT(selectItemsFromOutlines(PageItem *, bool)));
 	connect(docCheckerPalette, SIGNAL(selectElement(PageItem *, bool, int)), this, SLOT(selectItemFromOutlines(PageItem *, bool, int)));
@@ -726,6 +749,8 @@ void ScribusMainWindow::initMenuBar()
 //	scrMenuMgr->addMenuItem(scrActions["editGradients"], "Edit", false);
 //	scrMenuMgr->addMenuItem(scrActions["editPatterns"], "Edit", false);
 	scrMenuMgr->addMenuItem(scrActions["editStyles"], "Edit", false);
+	scrMenuMgr->addMenuItem(scrActions["editMarks"], "Edit", false);
+	scrMenuMgr->addMenuItem(scrActions["editNotesSets"], "Edit", false);
 	scrMenuMgr->addMenuItem(scrActions["editMasterPages"], "Edit", false);
 	scrMenuMgr->addMenuItem(scrActions["editJavascripts"], "Edit", false);
 	scrMenuMgr->setMenuEnabled("EditPasteRecent", false);
@@ -845,6 +870,9 @@ void ScribusMainWindow::initMenuBar()
 	scrMenuMgr->addMenuItem(scrActions["itemWeld"], "Item", false);
 	scrMenuMgr->addMenuItem(scrActions["itemEditWeld"], "Item", false);
 
+	scrMenuMgr->addMenuItem(scrActions["editMark"], "Item", false);
+	scrMenuMgr->addMenuItem(scrActions["itemUpdateMarks"], "Item", false);
+
 	//Insert menu
 	scrMenuMgr->createMenu("Insert", ActionManager::defaultMenuNameEntryTranslated("Insert"));
 	scrMenuMgr->addMenuItem(scrActions["insertFrame"], "Insert", false);
@@ -934,6 +962,14 @@ void ScribusMainWindow::initMenuBar()
 
 	scrMenuMgr->addMenuSeparator("Insert");
 	scrMenuMgr->addMenuItem(scrActions["insertSampleText"], "Insert", false);
+	scrMenuMgr->addMenuSeparator("Insert");
+	scrMenuMgr->createMenu("InsertMark", tr("Marks"), "Insert");
+	scrMenuMgr->addMenuItem(scrActions["insertMarkAnchor"], "InsertMark", false);
+	scrMenuMgr->addMenuItem(scrActions["insertMarkVariableText"], "InsertMark", false);
+	scrMenuMgr->addMenuItem(scrActions["insertMarkItem"], "InsertMark", false);
+	scrMenuMgr->addMenuItem(scrActions["insertMark2Mark"], "InsertMark", false);
+	scrMenuMgr->addMenuItem(scrActions["insertMarkNote"], "InsertMark", false);
+//	scrMenuMgr->addMenuItem(scrActions["insertMarkIndex"], "InsertMark", false);
 
 	//Page menu
 	scrMenuMgr->createMenu("Page", ActionManager::defaultMenuNameEntryTranslated("Page"));
@@ -1137,6 +1173,8 @@ void ScribusMainWindow::setStatusBarInfoText(QString newText)
 //AV to be replaced with Selection::update and listener in PropertiesPalette
 void ScribusMainWindow::setTBvals(PageItem *currItem)
 {
+	scrActions["editMark"]->setEnabled(false);
+	scrActions["itemUpdateMarks"]->setEnabled(false);
 	if (currItem->itemText.length() != 0)
 	{
 //		int ChPos = qMin(currItem->CPos, static_cast<int>(currItem->itemText.length()-1));
@@ -1150,6 +1188,20 @@ void ScribusMainWindow::setTBvals(PageItem *currItem)
 		emit TextStyle(doc->currentStyle);
 		// to go: (av)
 		propertiesPalette->textPal->updateStyle(doc->currentStyle);
+		//check if mark in cursor place and enable editMark action
+		if (doc->appMode == modeEdit && currItem->itemText.cursorPosition() < currItem->itemText.length())
+		{
+			ScText *hl = currItem->itemText.item(currItem->itemText.cursorPosition());
+			if (hl->hasMark())
+			{
+				scrActions["editMark"]->setEnabled(true);
+				if ((hl->mark->isType(MARKNoteMasterType) || hl->mark->isType(MARKNoteFrameType)) && (hl->mark->getNotePtr() != NULL))
+					nsManager->setNSet(hl->mark->getNotePtr()->notesSet());
+			}
+			else
+				scrActions["editMark"]->setEnabled(false);
+		}
+		scrActions["itemUpdateMarks"]->setEnabled(currItem->asTextFrame()->hasAnyMark());
 	}
 }
 
@@ -1174,7 +1226,12 @@ void ScribusMainWindow::specialActionKeyEvent(const QString& actionName, int uni
 					if (unicodevalue!=-1)
 					{
 						if (currItem->HasSel)
+						{
+							//removing marks and notes from selected text
+							if (currItem->isTextFrame() && !currItem->asTextFrame()->removeMarksFromText(!ScCore->usingGUI()))
+								return;
 							currItem->deleteSelectedTextFromFrame();
+						}
 						currItem->itemText.insertChars(QString(QChar(unicodevalue)), true);
 					}
 					else if (actionName=="unicodeSoftHyphen") //ignore the char as we use an attribute if the text item, for now.
@@ -1566,6 +1623,8 @@ void ScribusMainWindow::keyPressEvent(QKeyEvent *k)
 					currItem->handleModeEditKey(k, keyrep);
 					keyrep=kr;
 				}
+				if (doc->flag_notesChanged)
+					doc->notesFramesUpdate();
 				slotDocCh(false);
 			}
 		}
@@ -1998,6 +2057,8 @@ ScribusDoc *ScribusMainWindow::doFileNew(double width, double height, double top
 		tempView->cmsToolbarButton->setChecked(tempDoc->HasCMS);
 		undoManager->switchStack(tempDoc->DocName);
 		styleManager->setDoc(tempDoc);
+		marksManager->setDoc(tempDoc);
+		nsManager->setDoc(tempDoc);
 		tocGenerator->setDoc(tempDoc);
 	}
 	undoManager->setUndoEnabled(true);
@@ -2224,6 +2285,8 @@ void ScribusMainWindow::newActWin(QMdiSubWindow *w)
 	docCheckerPalette->setDoc(doc);
 	tocGenerator->setDoc(doc);
 	styleManager->setDoc(doc);
+	marksManager->setDoc(doc);
+	nsManager->setDoc(doc);
 	symbolPalette->setDoc(doc);
 	inlinePalette->setDoc(doc);
 	modeToolBar->Angle->setValue(doc->itemToolPrefs().calligrapicPenAngle);
@@ -2256,6 +2319,8 @@ void ScribusMainWindow::SwitchWin()
 	updateActiveWindowCaption(doc->DocName);
 // 	scrActions["shade100"]->setChecked(true);
 	propertiesPalette->setDoc(doc);
+	marksManager->setDoc(doc);
+	nsManager->setDoc(doc);
 	//propertiesPalette->Cpal->displayGradient(0);
 	pagePalette->setView(view);
 	layerPalette->setDoc(doc);
@@ -2396,6 +2461,8 @@ void ScribusMainWindow::HaveNewDoc()
 //	scrActions["editPatterns"]->setEnabled(true);
 //	scrActions["editGradients"]->setEnabled(true);
  	scrActions["editStyles"]->setEnabled(true);
+	scrActions["editMarks"]->setEnabled(true);
+	scrActions["editNotesSets"]->setEnabled(true);
 	scrActions["editMasterPages"]->setEnabled(true);
 	scrActions["editJavascripts"]->setEnabled(true);
 
@@ -2461,6 +2528,7 @@ void ScribusMainWindow::HaveNewDoc()
 	updateActiveWindowCaption(doc->DocName);
 // 	scrActions["shade100"]->setChecked(true);
 	propertiesPalette->setDoc(doc);
+	nsManager->setDoc(doc);
 	symbolPalette->setDoc(doc);
 	inlinePalette->setDoc(doc);
 //	propertiesPalette->Cpal->displayGradient(0);
@@ -2820,6 +2888,9 @@ void ScribusMainWindow::HaveNewSel(int SelectedType)
 		scrActions["toolsCopyProperties"]->setEnabled(true);
 		scrActions["toolsEditWithStoryEditor"]->setEnabled(true);
 		scrActions["insertSampleText"]->setEnabled(true);
+		scrActions["itemUpdateMarks"]->setEnabled(currItem->asTextFrame()->hasAnyMark());
+		scrMenuMgr->setMenuEnabled("InsertMark",true);
+
 		if ((currItem->nextInChain() != 0) || (currItem->prevInChain() != 0))
 		{
 			scrActions["itemConvertToBezierCurve"]->setEnabled(false);
@@ -2852,14 +2923,20 @@ void ScribusMainWindow::HaveNewSel(int SelectedType)
 			setTBvals(currItem);
 			scrActions["editSelectAll"]->setEnabled(true);
 			scrActions["editSelectAllOnLayer"]->setEnabled(false);
+			scrActions["insertSampleText"]->setEnabled(true);
+			scrMenuMgr->setMenuEnabled("InsertMark",true);
 			charPalette->setEnabled(true, currItem);
 			if (currItem->asTextFrame())
+			{
 				enableTextActions(&scrActions, true, currItem->currentStyle().charStyle().font().scName());
+				currItem->asTextFrame()->togleEditModeActions();
+			}
 			view->horizRuler->setItem(currItem);
 			view->horizRuler->update();
 		}
 		else
 		{
+			scrMenuMgr->setMenuEnabled("InsertMark",false);
 			doc->currentStyle = currItem->itemText.defaultStyle();
 			propertiesPalette->textPal->displayParStyle(doc->currentStyle.parent());
 			propertiesPalette->textPal->displayCharStyle(doc->currentStyle.charStyle().parent());
@@ -3261,6 +3338,16 @@ void ScribusMainWindow::slotDocCh(bool /*reb*/)
 		Q_ASSERT(plugin); // all the returned names should represent loaded plugins
 		plugin->changedDoc(doc);
 	}
+	static int markersCount; //remember marks count from last call
+	if (markersCount != doc->m_docMarksList.count() || doc->flag_notesChanged || doc->flag_updateEndNotes)
+	{
+		markersCount = doc->m_docMarksList.count();
+		doc->updateMarks(doc->flag_notesChanged);
+		emit UpdateRequest(reqMarksUpdate);
+	}
+	else if (doc->flag_updateNotesLabels)
+		emit UpdateRequest(reqMarksUpdate);
+	doc->updateChangedEndNotesFrames();
 }
 
 void ScribusMainWindow::updateRecent(QString fn)
@@ -4052,7 +4139,7 @@ bool ScribusMainWindow::loadDoc(QString fileName)
 		for (int azz=0; azz<docItemsCount; ++azz)
 		{
 			PageItem *ite = doc->Items->at(azz);
-			if(ite->nextInChain() == NULL)
+			if((ite->nextInChain() == NULL) && !ite->isNoteFrame())  //do not layout notes frames
 				ite->layout();
 /*			if (doc->OldBM)
 			{
@@ -4084,6 +4171,7 @@ bool ScribusMainWindow::loadDoc(QString fileName)
 		{
 			Apply_MasterPage(doc->DocPages.at(p)->MPageNam, p, false);
 		}
+		doc->updateMarks(true);
 		view->reformPages(false);
 		doc->setLoading(false);
 /*		if (fileLoader->FileType > FORMATID_NATIVEIMPORTEND)
@@ -4132,6 +4220,8 @@ bool ScribusMainWindow::loadDoc(QString fileName)
 	qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
 	undoManager->setUndoEnabled(true);
 	doc->setModified(false);
+	foreach (NotesSet* NS, doc->m_docNotesSetsList)
+		doc->updateNotesFramesStyles(NS);
 #ifdef DEBUG_LOAD_TIMES
 	times(&tms2);
 	double ticks = sysconf(_SC_CLK_TCK);
@@ -4214,6 +4304,8 @@ void ScribusMainWindow::slotGetContent()
 			view->DrawNew();
 			slotDocCh();
 			styleManager->setDoc(doc);
+			marksManager->setDoc(doc);
+			nsManager->setDoc(doc);
 		}
 	}
 }
@@ -4620,6 +4712,8 @@ bool ScribusMainWindow::DoFileClose()
 //		scrActions["editPatterns"]->setEnabled(false);
 //		scrActions["editGradients"]->setEnabled(false);
 		scrActions["editStyles"]->setEnabled(false);
+		scrActions["editMarks"]->setEnabled(false);
+		scrActions["editNotesSets"]->setEnabled(false);
 		scrActions["editSearchReplace"]->setEnabled(false);
 		scrActions["editMasterPages"]->setEnabled(false);
 		scrActions["editJavascripts"]->setEnabled(false);
@@ -4726,6 +4820,8 @@ bool ScribusMainWindow::DoFileClose()
 	charPalette->setDoc(0);
 	tocGenerator->setDoc(0);
 	styleManager->setDoc(0);
+	marksManager->setDoc(0);
+	nsManager->setDoc(0);
 	layerPalette->ClearInhalt();
 	docCheckerPalette->buildErrorList(0);
 	HaveDoc--;
@@ -4944,6 +5040,9 @@ void ScribusMainWindow::slotEditCut()
 			{
 				if ((cItem->itemText.length() == 0) || (!cItem->HasSel))
 					return;
+				//removing marks and notes from selected text
+				if (cItem->isTextFrame() && !cItem->asTextFrame()->removeMarksFromText(!ScCore->usingGUI()))
+					return;
 				StoryText itemText(doc);
 				itemText.setDefaultStyle(cItem->itemText.defaultStyle());
 				itemText.insert(0, cItem->itemText, true);
@@ -5083,7 +5182,12 @@ void ScribusMainWindow::slotEditPaste()
 				currItem = selItem->asTextFrame();
 			assert(currItem != NULL);
 			if (currItem->HasSel)
+			{
+				//removing marks and notes from selected text
+				if (currItem->isTextFrame() && !currItem->asTextFrame()->removeMarksFromText(!ScCore->usingGUI()))
+					return;
 				currItem->deleteSelectedTextFromFrame();
+			}
 
 			/*if (currItem->CPos < 0)
 				currItem->CPos = 0;
@@ -5092,7 +5196,9 @@ void ScribusMainWindow::slotEditPaste()
 
 			if (ScMimeData::clipboardHasScribusText())
 			{
-				Serializer dig(*doc); // TODO: do we really need a new serializer here?
+				// TODO: do we really need a new serializer here?
+				//cezaryece - now yes, we do for marks
+				Serializer dig(doc);
 				dig.store<ScribusDoc>("<scribusdoc>", doc);
 				StoryText::desaxeRules("/", dig, "SCRIBUSTEXT");
 				dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
@@ -5102,8 +5208,18 @@ void ScribusMainWindow::slotEditPaste()
 
 				StoryText* story = dig.result<StoryText>();
 
+				//avoid pasting notes marks into notes frames
+				if (currItem->isNoteFrame())
+				{
+					story->setDoc(doc);
+					for (int pos=story->length() -1; pos >= 0; --pos)
+					{
+						ScText* hl = story->item(pos);
+						if (hl->hasMark() && (hl->mark->isNoteType()))
+							story->removeChars(pos,1);
+					}
+				}
 				currItem->itemText.insert(*story);
-
 				delete story;
 			}
 			else if (ScMimeData::clipboardHasScribusElem() || ScMimeData::clipboardHasScribusFragment())
@@ -5126,6 +5242,8 @@ void ScribusMainWindow::slotEditPaste()
 				styleManager->setDoc(doc);
 				propertiesPalette->unsetDoc();
 				propertiesPalette->setDoc(doc);
+				marksManager->setDoc(doc);
+				nsManager->setDoc(doc);
 				symbolPalette->unsetDoc();
 				symbolPalette->setDoc(doc);
 
@@ -5209,6 +5327,8 @@ void ScribusMainWindow::slotEditPaste()
 				styleManager->setDoc(doc);
 				propertiesPalette->unsetDoc();
 				propertiesPalette->setDoc(doc);
+				marksManager->setDoc(doc);
+				nsManager->setDoc(doc);
 				symbolPalette->unsetDoc();
 				symbolPalette->setDoc(doc);
 				inlinePalette->unsetDoc();
@@ -5250,6 +5370,8 @@ void ScribusMainWindow::slotEditPaste()
 			delete activeTransaction;
 			activeTransaction = NULL;
 		}
+		if (doc->flag_notesChanged)
+			doc->notesFramesUpdate();
 		slotDocCh(false);
 	}
 }
@@ -5562,6 +5684,7 @@ void ScribusMainWindow::slotNewPageP(int wo, QString templ)
 		doc->addPageToSection(wo, where, 1);
 	else
 		doc->addPageToSection(wo+1, where, 1);
+	doc->updateEndnotesFrames();
 	doc->changed();
 	updateGUIAfterPagesChanged();
 }
@@ -5688,6 +5811,7 @@ void ScribusMainWindow::addNewPages(int wo, int where, int numPages, double heig
 	doc->changed();
 	doc->addPageToSection(wo, where, numPages);
 	doc->reformPages();
+	doc->updateEndnotesFrames();
 	updateGUIAfterPagesChanged();
 
 	undoManager->setUndoEnabled(true);
@@ -6487,13 +6611,17 @@ void ScribusMainWindow::setAppMode(int mode)
 //					view->requestMode(modeEditClip);
 //					return;
 //				}
-				setTBvals(currItem);
+				//setTBvals before placing cursor has no effect
 				currItem->itemText.setCursorPosition(0);
+				setTBvals(currItem);
 			}
 			scrActions["editPaste"]->setEnabled(false);
 			charPalette->setEnabled(true, currItem);
-			if (currItem!=NULL && currItem->asTextFrame())
+			if ((currItem != NULL) && currItem->asTextFrame())
+			{
 				enableTextActions(&scrActions, true, currItem->currentCharStyle().font().scName());
+				currItem->asTextFrame()->togleEditModeActions();
+			}
 			if (ScMimeData::clipboardHasScribusData())
 			{
 				bool textFrameEditMode = ((currItem != NULL) && (currItem->asTextFrame()));
@@ -6537,6 +6665,9 @@ void ScribusMainWindow::setAppMode(int mode)
 // 				currItem->update();
 			}
 		}
+		//disable text action which work only text frame in edit mode
+		if ((mode != modeEdit) || !currItem->isTextFrame())
+			enableTextActions(&scrActions, false);
 		int docSelectionCount=doc->m_Selection->count();
 		if (mode == modeDrawBezierLine)
 		{
@@ -6800,6 +6931,9 @@ void ScribusMainWindow::deletePage(int from, int to)
 		for (int d = 0; d < doc->Items->count(); ++d)
 		{
 			ite = doc->Items->at(d);
+			//do not delete notes frames
+			if (ite->isNoteFrame())
+				continue;
 			if (ite->OwnPage == a)
 			{
 				ite->setLocked(false);
@@ -6851,6 +6985,7 @@ void ScribusMainWindow::deletePage(int from, int to)
 	view->reformPagesView();
 	undoManager->setUndoEnabled(true); // ugly hack continues
 	view->GotoPage(qMin(doc->Pages->count()-1, oldPg));
+	doc->updateEndnotesFrames();
 	updateGUIAfterPagesChanged();
 	doc->rebuildMasterNames();
 	pagePalette->rebuildMasters();
@@ -6878,6 +7013,7 @@ void ScribusMainWindow::movePage()
 			doc->movePage(from-1, to, wo-1, wie);
 			updateGUIAfterPagesChanged();
 		}
+		doc->updateEndnotesFrames();
 	}
 	delete dia;
 }
@@ -6895,6 +7031,7 @@ void ScribusMainWindow::copyPage()
 		int wo = dia->getWherePage();
 		doc->copyPage(pageNumberToCopy, wo, whereToInsert, copyCount);
 		view->Deselect(true);
+		doc->updateEndnotesFrames();
 		updateGUIAfterPagesChanged();
 		slotDocCh();
 	}
@@ -6932,6 +7069,7 @@ void ScribusMainWindow::changePageMargins()
 			if (dia->masterPage() != Nam)
 				Apply_MasterPage(dia->masterPage(), doc->currentPage()->pageNr());
 		}
+		doc->updateEndnotesFrames();
 		//CB: Moved to changePageMargins for #2338
 		//doc->currentPage()->marginPreset = dia->getMarginPreset();
 		//view->reformPages(dia->getMoveObjects());
@@ -7782,6 +7920,8 @@ int ScribusMainWindow::ShowSubs()
 	inlinePalette->startup();
 	charPalette->startup();
 	styleManager->startup();
+	marksManager->startup();
+	nsManager->startup();
 	symbolPalette->startup();
 
 	// init the toolbars
@@ -10141,6 +10281,17 @@ void ScribusMainWindow::enableTextActions(QMap<QString, QPointer<ScrAction> > *a
 	scrMenuMgr->setMenuEnabled("InsertQuote", enabled);
 	scrMenuMgr->setMenuEnabled("InsertSpace", enabled);
 	scrMenuMgr->setMenuEnabled("InsertLigature", enabled);
+	scrMenuMgr->setMenuEnabled("InsertMark", enabled);
+	if (!enabled)
+	{
+		scrActions["insertMarkVariableText"]->setEnabled(false);
+		scrActions["insertMarkAnchor"]->setEnabled(false);
+		scrActions["insertMarkItem"]->setEnabled(false);
+		scrActions["insertMark2Mark"]->setEnabled(false);
+		scrActions["insertMarkNote"]->setEnabled(false);
+		scrActions["editMark"]->setEnabled(false);
+	}
+	scrActions["itemUpdateMarks"]->setEnabled(enabled);
 }
 
 void ScribusMainWindow::updateGUIAfterPagesChanged()
@@ -10192,3 +10343,419 @@ void ScribusMainWindow::updateTableMenuActions()
 	scrActions["tableAdjustTableToFrame"]->setEnabled(table);
 }
 
+void ScribusMainWindow::insertMark(MarkType mType)
+{
+	if (!HaveDoc)
+		return;
+	if (doc->m_Selection->count() != 1)
+		return;
+	if  (doc->appMode != modeEdit)
+		return;
+	PageItem* currItem = doc->m_Selection->itemAt(0);
+	if (currItem->isTextFrame())
+	{
+		if (currItem->HasSel)
+		{
+			//inserting mark replace some selected text
+			//remove from selected text all marks
+			//ask user if any notes will be removed
+			if (!currItem->asTextFrame()->removeMarksFromText(!ScCore->usingGUI()))
+				return;
+		}
+		if (insertMarkDlg(currItem->asTextFrame(), mType))
+		{
+			Mark* mrk = NULL;
+			view->updatesOn(false);
+			currItem->invalidateLayout();
+			if (mType == MARKNoteMasterType)
+			{
+				mrk = currItem->itemText.item(currItem->itemText.cursorPosition() -1)->mark;
+				if (doc->updateNotesNums(mrk->getNotePtr()->notesSet()))
+				{
+					if (mrk->getNotePtr()->isEndNote())
+						doc->flag_updateEndNotes = true;
+					currItem->asTextFrame()->notesFramesLayout(true);
+					doc->flag_updateEndNotes = false;
+				}
+			}
+			else
+			{
+				currItem->layout();
+				doc->changed();
+			}
+			view->updatesOn(true);
+			doc->regionsChanged()->update(currItem->getBoundingRect());
+			view->DrawNew();
+			if ((mrk != NULL) && (mrk->getNotePtr() != NULL))
+				doc->setCursor2MarkPos(mrk->getNotePtr()->noteMark());
+		}
+	}
+}
+
+void ScribusMainWindow::slotEditMark()
+{
+	if (!HaveDoc)
+		return;
+	if (doc->m_Selection->count() != 1)
+		return;
+	if  (doc->appMode != modeEdit)
+		return;
+	PageItem * currItem = doc->m_Selection->itemAt(0);
+	if (currItem->itemText.cursorPosition() < currItem->itemText.length())
+	{
+		ScText *hl = currItem->itemText.item(currItem->itemText.cursorPosition());
+		if (hl->hasMark())
+		{
+			if (editMarkDlg(hl->mark, currItem->asTextFrame()))
+			{
+				currItem->layout();
+				doc->updateMarks();
+				doc->changed();
+				doc->regionsChanged()->update(QRectF());
+			}
+		}
+	}
+}
+
+void ScribusMainWindow::slotUpdateMarks()
+{
+	if (!HaveDoc)
+		return;
+	if (doc->m_docMarksList.isEmpty())
+		return;
+	if (doc->updateMarks(true))
+	{
+		doc->changed();
+		doc->regionsChanged()->update(QRectF());
+	}
+}
+
+bool ScribusMainWindow::insertMarkDlg(PageItem_TextFrame* currItem, MarkType mrkType)
+{
+	if (doc->masterPageMode() && (mrkType != MARKVariableTextType))
+		//avoid inserting in master pages other marks than Variable Text
+		return false;
+	
+	MarkInsertDlg* insertMDialog = NULL;
+	switch (mrkType)
+	{
+	case MARKAnchorType:
+		insertMDialog = (MarkInsertDlg*) new MarkAnchorDlg(this);
+		break;
+	case MARKVariableTextType:
+		insertMDialog = (MarkInsertDlg*) new MarkVariableTextDlg(doc->m_docMarksList, this);
+		break;
+	case MARK2ItemType:
+		insertMDialog = (MarkInsertDlg*) new Mark2ItemDlg(this);
+		break;
+	case MARK2MarkType:
+		insertMDialog = (MarkInsertDlg*) new Mark2MarkDlg(doc->m_docMarksList, NULL, this);
+		break;
+	case MARKNoteMasterType:
+		insertMDialog = (MarkInsertDlg*) new MarkNoteDlg(doc->m_docNotesSetsList, this);
+		break;
+	case MARKIndexType:
+		break;
+	default:
+		break;
+	}
+	if (insertMDialog == NULL)
+	{
+		qDebug() << "Dialog not implemented for such marks type " << mrkType;
+		return false;
+	}
+	insertMDialog->setWindowTitle(tr("Insert new ") + insertMDialog->windowTitle());
+	if (insertMDialog->exec())
+	{
+		Mark* Mrk = NULL;
+		MarkData d;
+		if (currItem != NULL)
+			d.itemName = currItem->itemName();
+		QString label = "", text = "";
+		NotesSet* NSet = NULL;
+		switch (mrkType)
+		{
+		case MARKAnchorType:
+			//only gets label for new mark
+			insertMDialog->values(label);
+			if (label.isEmpty())
+				label = tr("Anchor mark");
+			d.itemPtr = currItem;
+			break;
+		case MARKVariableTextType:
+			Mrk = insertMDialog->values(label, text);
+			if ((Mrk == NULL) && (text.isEmpty()))
+				return false; //FIX ME here user should be warned that inserting of mark fails and why
+			if (label.isEmpty())
+				label = tr("Mark with <%1> variable text").arg(text);
+			d.strtxt = text;
+			break;
+		case MARK2ItemType:
+			insertMDialog->values(label, d.itemPtr);
+			if (d.itemPtr == NULL)
+				return false; //FIX ME here user should be warned that inserting of mark fails and why
+			if (label.isEmpty())
+				label = tr("Mark to %1 item").arg(d.itemPtr->itemName());
+			d.strtxt = QString::number(d.itemPtr->OwnPage +1);
+			break;
+		case MARK2MarkType:
+			//gets pointer to referenced mark
+			Mark* mrkPtr;
+			insertMDialog->values(label, mrkPtr);
+			if (mrkPtr == NULL)
+				return false; //FIX ME here user should be warned that inserting of mark fails and why
+			if (label.isEmpty())
+				label = tr("Mark to %1 mark").arg(mrkPtr->label);
+			d.strtxt = QString::number(mrkPtr->OwnPage +1);
+			d.destmarkName = mrkPtr->label;
+			d.destmarkType = mrkPtr->getType();
+			break;
+		case MARKNoteMasterType:
+			//gets pointer to choosed notes set
+			NSet = insertMDialog->values();
+			if (NSet == NULL)
+				return false;
+			
+			d.notePtr = new TextNote(NSet);
+			doc->m_docNotesList.append(d.notePtr);
+			label = "NoteMark_" + NSet->name();
+			if (NSet->range() == NSRsection)
+				label += " in section " + doc->getSectionNameForPageIndex(currItem->OwnPage) + " page " + QString::number(currItem->OwnPage +1);
+			else if (NSet->range() == NSRpage)
+				label += " on page " + QString::number(currItem->OwnPage +1);
+			else if (NSet->range() == NSRstory)
+				label += " in " + currItem->firstInChain()->itemName();
+			else if (NSet->range() == NSRframe)
+				label += " in frame" + currItem->itemName();
+			break;
+		case MARKIndexType:
+				return false;
+			break;
+		default:
+				return false;
+			break;
+		}
+		if (Mrk == NULL)
+		{
+			//check if label for new mark can be used as is
+			if (mrkType == MARKNoteMasterType)
+			{
+				if (doc->getMarkDefinied(label + "_1", mrkType) != NULL)
+					getUniqueName(label,doc->marksLabelsList(mrkType), "_"); //FIX ME here user should be warned that inserted mark`s label was changed
+				else
+					label = label + "_1";
+			}
+			else
+				getUniqueName(label,doc->marksLabelsList(mrkType), "_");
+			Mrk = new Mark;
+			Mrk->setValues(label, currItem->OwnPage, mrkType, d);
+			doc->m_docMarksList.append(Mrk);
+		}
+		else
+		{ // that must be variable text mark
+			Mrk->setString(d.strtxt);
+			doc->invalidateMarkMasterText(Mrk, true);
+		}
+
+		currItem->itemText.insertMark(Mrk);
+		Mrk->OwnPage = currItem->OwnPage;
+
+
+		if (mrkType == MARKNoteMasterType)
+		{
+			Mrk->getNotePtr()->setMasterMark(Mrk);
+			Mrk->setString("");
+		}
+		delete insertMDialog;
+		return true;
+	}
+	delete insertMDialog;
+	return false;
+}
+
+bool ScribusMainWindow::editMarkDlg(Mark *mrk, PageItem_TextFrame* currItem)
+{
+	MarkInsertDlg* editMDialog = NULL;
+	switch (mrk->getType())
+	{
+		case MARKAnchorType:
+			editMDialog = (MarkInsertDlg*) new MarkAnchorDlg(this);
+			editMDialog->setValues(mrk->label);
+			break;
+		case MARKVariableTextType:
+			if (currItem == NULL)
+				//invoked from Marks Manager
+				editMDialog = (MarkInsertDlg*) new MarkVariableTextDlg(mrk, this);
+			else
+				//invoked from mark`s entry in text
+				editMDialog = (MarkInsertDlg*) new MarkVariableTextDlg(doc->m_docMarksList, this);
+			editMDialog->setValues(mrk->label, mrk->getString());
+			break;
+		case MARK2ItemType:
+			editMDialog = (MarkInsertDlg*) new Mark2ItemDlg(this);
+			editMDialog->setValues(mrk->label, mrk->getItemPtr());
+			break;
+		case MARK2MarkType:
+			{
+				editMDialog = (MarkInsertDlg*) new Mark2MarkDlg(doc->m_docMarksList, mrk, this);
+				QString l;
+				MarkType t;
+				mrk->getMark(l,t);
+				Mark* m = doc->getMarkDefinied(l,t);
+				editMDialog->setValues(mrk->label, m);
+			}
+			break;
+		case MARKNoteMasterType:
+			{
+				//invoking editing note mark from master text
+				//so we go to edit note
+				TextNote* note = mrk->getNotePtr();
+				if (note == NULL)
+				{
+					qFatal("ScribusMainWindow::editMarkDlg - found note master mark with null pointer to note");
+					return false;
+				}
+				Mark* noteMark = note->noteMark();
+				doc->setCursor2MarkPos(noteMark);
+			}
+			break;
+		case MARKNoteFrameType:
+			{
+				//invoking editing mark from note frame
+				//so we go to master text
+				TextNote* note = mrk->getNotePtr();
+				if (note == NULL)
+				{
+					qFatal("ScribusMainWindow::editMarkDlg - found note frame mark with null pointer to note");
+					return false;
+				}
+				Mark* masterMark = note->masterMark();
+				doc->setCursor2MarkPos(masterMark);
+			}
+		case MARKIndexType:
+			return false;
+			break;
+		default:
+			break;
+	}
+	if (editMDialog == NULL) return false;
+
+	bool docWasChanged = false;
+
+	editMDialog->setWindowTitle(tr("Edit ") + editMDialog->windowTitle());
+	if (editMDialog->exec())
+	{
+		Mark* Mrk = NULL;
+		MarkData d;
+		if (currItem != NULL)
+			d.itemName = currItem->itemName();
+		QString label = "", text = "";
+		QString oldStr = mrk->getString();
+		switch (mrk->getType())
+		{
+			case MARKAnchorType:
+				//only gets label for new mark
+				editMDialog->values(label);
+				if (label.isEmpty())
+					label = tr("Anchor mark");
+				if (mrk->label != label)
+				{
+					getUniqueName(label,doc->marksLabelsList(mrk->getType()), "_"); //FIX ME here user should be warned that inserted mark`s label was changed
+					mrk->label = label;
+					emit UpdateRequest(reqMarksUpdate);
+				}
+				break;
+			case MARKVariableTextType:
+				Mrk = editMDialog->values(label, text);
+				if (text.isEmpty())
+					return false; //FIX ME here user should be warned that editing of mark fails and why
+				if (label.isEmpty())
+					label = tr("Mark with <%1> variable text").arg(text);
+				if (Mrk != NULL)
+				{
+					if (Mrk != mrk)
+					{
+						ScText* hl = currItem->itemText.item(currItem->itemText.cursorPosition());
+						hl->mark = Mrk;
+						mrk = Mrk;
+					}
+					if (mrk->label != label)
+					{
+						getUniqueName(label,doc->marksLabelsList(mrk->getType()), "_"); //FIX ME here user should be warned that inserted mark`s label was changed
+						mrk->label = label;
+						emit UpdateRequest(reqMarksUpdate);
+					}
+					if (text != oldStr)
+					{
+						mrk->setString(text);
+						if (mrk->getString() != oldStr)
+							docWasChanged = doc->invalidateMarkMasterText(mrk, true);
+					}
+				}
+				else
+				{
+					d.strtxt = text;
+					Mrk = new Mark;
+					getUniqueName(label,doc->marksLabelsList(mrk->getType()), "_"); //FIX ME here user should be warned that inserted mark`s label was changed
+					Mrk->setValues(label, currItem->OwnPage, MARKVariableTextType, d);
+					doc->m_docMarksList.append(Mrk);
+					ScText* hl = currItem->itemText.item(currItem->itemText.cursorPosition());
+					hl->mark = Mrk;
+					docWasChanged = true;
+				}
+				break;
+			case MARK2ItemType:
+				editMDialog->values(label, d.itemPtr);
+				if (d.itemPtr == NULL)
+					return false; //FIX ME here user should be warned that inserting of mark fails and why
+				if (label.isEmpty())
+					label = tr("Mark to %1 item").arg(d.itemPtr->itemName());
+				if (d.itemPtr != mrk->getItemPtr())
+				{
+					mrk->setItemPtr(d.itemPtr);
+					mrk->setString(QString("%1").arg(d.itemPtr->OwnPage +1));
+					docWasChanged = true;
+				}
+				if (mrk->label != label)
+				{
+					getUniqueName(label,doc->marksLabelsList(mrk->getType()), "_"); //FIX ME here user should be warned that inserted mark`s label was changed
+					mrk->label = label;
+					emit UpdateRequest(reqMarksUpdate);
+				}
+				break;
+			case MARK2MarkType:
+				{
+					//gets pointer to referenced mark
+					Mark* mrkPtr = NULL;
+					editMDialog->values(label, mrkPtr);
+					if (mrkPtr == NULL)
+						return false; //FIX ME here user should be warned that inserting of mark fails and why
+					if (label.isEmpty())
+						label = tr("Mark to %1 mark").arg(mrkPtr->label);
+					QString destLabel = mrkPtr->label;
+					MarkType destType = mrkPtr->getType();
+					if (d.destmarkName != destLabel || d.destmarkType != destType)
+					{
+						mrk->setMark(mrkPtr);
+						mrk->setString(QString("%1").arg(mrkPtr->OwnPage +1));
+						docWasChanged = true;
+					}
+					if (mrk->label != label)
+					{
+						getUniqueName(label,doc->marksLabelsList(mrk->getType()), "_"); //FIX ME here user should be warned that inserted mark`s label was changed
+						mrk->label = label;
+						emit UpdateRequest(reqMarksUpdate);
+					}
+				}
+				break;
+			case MARKNoteMasterType:
+				break;
+			case MARKIndexType:
+				break;
+			default:
+				break;
+		}
+	}
+	delete editMDialog;
+	return docWasChanged;
+}
diff --git a/Scribus/scribus/scribus.h b/Scribus/scribus/scribus.h
index 042af8f..9d80b29 100644
--- a/Scribus/scribus/scribus.h
+++ b/Scribus/scribus/scribus.h
@@ -75,10 +75,12 @@ class GuideManager;
 class HelpBrowser;
 class InlinePalette;
 class LayerPalette;
+class MarksManager;
 class Measurements;
 class ScMWMenuManager;
 class ModeToolBar;
 class NodePalette;
+class NotesSetsManager;
 class OutlinePalette;
 class PDFToolBar;
 class PSLib;
@@ -209,6 +211,8 @@ public:
 	GuideManager *guidePalette;
 	CharSelect *charPalette;
 	PropertiesPalette *propertiesPalette;
+	MarksManager *marksManager;
+	NotesSetsManager *nsManager;
 	NodePalette *nodePalette;
 	OutlinePalette *outlinePalette;
 	Biblio *scrapbookPalette;
@@ -608,6 +612,22 @@ private:
 	FormatsManager *formatsManager;
 
 	QPointer<HelpBrowser> helpBrowser;
+
+public slots:
+	//inserting marks
+	void slotInsertMark2Mark() { insertMark(MARK2MarkType); }
+	void slotInsertMarkAnchor() { insertMark(MARKAnchorType); }
+	void slotInsertMarkVariableText() { insertMark(MARKVariableTextType); }
+	void slotInsertMarkItem() { insertMark(MARK2ItemType); }
+	void slotInsertMarkNote() { insertMark(MARKNoteMasterType); }
+	void slotInsertMarkIndex() { insertMark(MARKIndexType); }
+	void slotEditMark();
+	//connected to signal emited by actions when "Update Marks" menu item is triggered
+	void slotUpdateMarks();
+	bool editMarkDlg(Mark *mrk, PageItem_TextFrame* currItem = NULL);
+private:
+	void insertMark(MarkType);
+	bool insertMarkDlg(PageItem_TextFrame* item, MarkType mT);
 };
 
 #endif
diff --git a/Scribus/scribus/scribusdoc.cpp b/Scribus/scribus/scribusdoc.cpp
index d6869d4..260df58 100644
--- a/Scribus/scribus/scribusdoc.cpp
+++ b/Scribus/scribus/scribusdoc.cpp
@@ -51,6 +51,7 @@ for which a new license (GPL+exception) is in place.
 #include "hyphenator.h"
 #include "ui/inserttablecolumnsdialog.h"
 #include "ui/inserttablerowsdialog.h"
+#include "notesset.h"
 #include "pageitem.h"
 #include "pageitem_imageframe.h"
 #include "pageitem_latexframe.h"
@@ -60,6 +61,7 @@ for which a new license (GPL+exception) is in place.
 #include "pageitem_polyline.h"
 #include "pageitem_table.h"
 #include "pageitem_textframe.h"
+#include "pageitem_noteframe.h"
 #ifdef HAVE_OSG
 	#include "pageitem_osgframe.h"
 #endif
@@ -101,6 +103,12 @@ for which a new license (GPL+exception) is in place.
 #include "colormgmt/sccolormgmtenginefactory.h"
 #include "ui/hruler.h"
 #include "ui/layers.h"
+#include "ui/MarkInsertDlg.h"
+#include "ui/mark2item.h"
+#include "ui/mark2mark.h"
+#include "ui/markanchor.h"
+#include "ui/markvariabletext.h"
+#include "ui/marksmanager.h"
 #include "ui/scmessagebox.h"
 #include "ui/storyeditor.h"
 
@@ -257,7 +265,12 @@ ScribusDoc::ScribusDoc() : UndoObject( tr("Document")), Observable<ScribusDoc>(N
 	m_alignTransaction(NULL),
 	m_currentPage(NULL),
 	m_updateManager(),
-	m_docUpdater(NULL)
+	m_docUpdater(NULL),
+	flag_notesChanged(false),
+	flag_restartMarksRenumbering(false),
+	flag_updateNotesLabels(false),
+	flag_updateEndNotes(false),
+	flag_layoutNotesFrames(true)
 {
 	docUnitRatio=unitGetRatioFromIndex(docPrefsData.docSetupPrefs.docUnitIndex);
 	docPrefsData.docSetupPrefs.pageHeight=0;
@@ -350,7 +363,12 @@ ScribusDoc::ScribusDoc(const QString& docName, int unitindex, const PageSize& pa
 	m_alignTransaction(NULL),
 	m_currentPage(NULL),
 	m_updateManager(),
-	m_docUpdater(NULL)
+	m_docUpdater(NULL),
+	flag_notesChanged(false),
+	flag_restartMarksRenumbering(false),
+	flag_updateNotesLabels(false),
+	flag_updateEndNotes(false),
+	flag_layoutNotesFrames(true)
 {
 	docPrefsData.docSetupPrefs.docUnitIndex=unitindex;
 	docPrefsData.docSetupPrefs.pageHeight=pagesize.height();
@@ -543,6 +561,9 @@ void ScribusDoc::init()
 	m_masterPageMode=true; // quick hack to force the change of pointers in setMasterPageMode();
 	setMasterPageMode(false);
 	addSymbols();
+	//for loading old documents where default notes set is not saved
+	if (m_docNotesSetsList.isEmpty())
+		m_docNotesSetsList.append(new NotesSet());
 }
 
 
@@ -644,6 +665,13 @@ ScribusDoc::~ScribusDoc()
 			delete pa.items.takeFirst();
 		}
 	}
+	//deleting resources alocated for marks and notes
+	while (! m_docNotesList.isEmpty())
+		delete m_docNotesList.takeFirst();
+	while (!m_docMarksList.isEmpty())
+		delete m_docMarksList.takeFirst();
+	while (! m_docNotesSetsList.isEmpty())
+		delete m_docNotesSetsList.takeFirst();
 	docPatterns.clear();
 	docGradients.clear();
 	while (!DocItems.isEmpty())
@@ -1247,6 +1275,16 @@ void ScribusDoc::replaceNamedResources(ResourceCollection& newNames)
 			itemlist = NULL;
 	}
 #endif
+	foreach (NotesSet* nSet, m_docNotesSetsList)
+	{ //update styles names in notessets
+		if (nSet == NULL)
+			continue;
+		if (newNames.styles().contains(nSet->notesParStyle()))
+			nSet->setNotesParStyle(newNames.styles().value(nSet->notesParStyle()));
+		if (newNames.charStyles().contains(nSet->marksChStyle()))
+			nSet->setMarksCharStyle(newNames.charStyles().value(nSet->marksChStyle()));
+	}
+
 	for (QHash<int, PageItem*>::iterator itf = FrameItems.begin(); itf != FrameItems.end(); ++itf)
 	{
 		PageItem *currItem = itf.value();
@@ -2290,6 +2328,7 @@ void ScribusDoc::movePage(const int fromPage, const int toPage, const int dest,
 		m_View->reformPagesView();
 		m_ScMW->updateGUIAfterPagesChanged();
 	}
+	updateEndnotesFrames();
 	changed();
 }
 
@@ -2349,6 +2388,7 @@ int ScribusDoc::addAutomaticTextFrame(const int pageNumber)
 			FirstAuto = Items->at(z);
 		LastAuto = Items->at(z);
 		Items->at(z)->setRedrawBounding();
+		updateEndnotesFrames();
 		return z;
 	}
 	return -1;
@@ -4763,7 +4803,7 @@ bool ScribusDoc::copyPageToMasterPage(const int pageNumber, const int leftPage,
 	return true;
 }
 
-int ScribusDoc::itemAdd(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double b, const double h, const double w, const QString& fill, const QString& outline, const bool itemFinalised)
+int ScribusDoc::itemAdd(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double b, const double h, const double w, const QString& fill, const QString& outline, const bool itemFinalised, const bool noteFrame)
 {
 	assert(itemFinalised); // av: caller must wrap transaction around this if wanted
 	UndoTransaction* activeTransaction = NULL;
@@ -4781,7 +4821,10 @@ int ScribusDoc::itemAdd(const PageItem::ItemType itemType, const PageItem::ItemF
 			Q_ASSERT(frameType==PageItem::Rectangle || frameType==PageItem::Unspecified);
 			break;
 		case PageItem::TextFrame:
-			newItem = new PageItem_TextFrame(this, x, y, b, h, w, CommonStrings::None, outline);
+			if (noteFrame)
+				newItem = new PageItem_NoteFrame(this, x, y, b, h, w, CommonStrings::None, outline);
+			else
+				newItem = new PageItem_TextFrame(this, x, y, b, h, w, CommonStrings::None, outline);
 			Q_ASSERT(frameType==PageItem::Rectangle || frameType==PageItem::Unspecified);
 			break;
 		case PageItem::Line:
@@ -6353,6 +6396,16 @@ int ScribusDoc::getSectionKeyForPageIndex(const uint pageIndex) const
 	return retVal;
 }
 
+QString ScribusDoc::getSectionNameForPageIndex(const uint pageIndex) const
+{
+	DocumentSectionMap::ConstIterator it = docPrefsData.docSectionMap.begin();
+	for (; it != docPrefsData.docSectionMap.end(); ++it)
+	{
+		if (pageIndex >= it.value().fromindex && pageIndex <= it.value().toindex)
+			return it.value().name;
+	}
+	return QString();
+}
 
 const QString ScribusDoc::getSectionPageNumberForPageIndex(const uint pageIndex) const
 {
@@ -8321,6 +8374,10 @@ void ScribusDoc::itemSelection_SetParagraphStyle(const ParagraphStyle & newStyle
 		}
 		else
 		{
+			if (currItem->isTextFrame() && !currItem->isNoteFrame())
+				updateItemNotesFramesStyles(currItem);
+			else if (currItem->isNoteFrame())
+				flag_notesChanged = true;
 			currItem->itemText.setDefaultStyle(newStyle);
 		}
 		if (currItem->asPathText())
@@ -8379,12 +8436,29 @@ void ScribusDoc::itemSelection_EraseParagraphStyle(Selection* customSelection)
 		else
 		{
 			ParagraphStyle newStyle;
-			newStyle.setParent(currItem->itemText.defaultStyle().parent());
+			if (currItem->isNoteFrame())
+			{
+				if (currItem->asNoteFrame()->masterFrame() != NULL)
+				{
+					newStyle.setParent(currItem->asNoteFrame()->masterFrame()->itemText.defaultStyle().parent());
+					newStyle.applyStyle(currItem->asNoteFrame()->masterFrame()->currentStyle());
+				}
+				else
+					newStyle.setParent(currItem->itemText.defaultStyle().parent());
+			}
 			currItem->itemText.setDefaultStyle(newStyle);
+			if (currItem->isTextFrame() && !currItem->isNoteFrame())
+				updateItemNotesFramesStyles(currItem);
+			else if (currItem->isNoteFrame())
+				flag_notesChanged = true;
 		}
 		currItem->invalid = true;
 		if (currItem->asPathText())
 			currItem->updatePolyClip();
+		if (currItem->isNoteFrame())
+			currItem->asNoteFrame()->updateNotesText();
+		else if (currItem->isTextFrame() && currItem->asTextFrame()->hasNoteFrame(NULL, true))
+			flag_notesChanged = true;
 	}
 	if (activeTransaction)
 	{
@@ -8415,6 +8489,23 @@ void ScribusDoc::itemSelection_ApplyParagraphStyle(const ParagraphStyle & newSty
 			ParagraphStyle dstyle(currItem->itemText.defaultStyle());
 			dstyle.applyStyle(newStyle);
 			currItem->itemText.setDefaultStyle(dstyle);
+			if (currItem->isTextFrame() && !currItem->isNoteFrame())
+			{
+				foreach (PageItem_NoteFrame* nF, currItem->asTextFrame()->notesFramesList())
+				{
+					if (nF->isEndNotesFrame())
+						continue;
+					NotesSet* nSet = nF->notesSet();
+					if (nSet->notesParStyle().isEmpty() || (nSet->notesParStyle() == tr("No Style")))
+					{
+						nF->itemText.setDefaultStyle(dstyle);
+						nF->invalid = true;
+						flag_notesChanged = true;
+					}
+				}
+			}
+			else if (currItem->isNoteFrame())
+				flag_notesChanged = true;
 		}
 		if (currItemTextCount > 0)
 		{
@@ -8439,6 +8530,10 @@ void ScribusDoc::itemSelection_ApplyParagraphStyle(const ParagraphStyle & newSty
 		}
 		if (currItem->asPathText())
 			currItem->updatePolyClip();
+		if (currItem->isNoteFrame())
+			currItem->asNoteFrame()->updateNotesText();
+		else if (currItem->isTextFrame() && currItem->asTextFrame()->hasNoteFrame(NULL, true))
+			flag_notesChanged = true;
 		currItem->invalidateLayout();
 	}
 	if (activeTransaction)
@@ -8496,9 +8591,28 @@ void ScribusDoc::itemSelection_ApplyCharStyle(const CharStyle & newStyle, Select
 //			if (currItem->asPathText())
 			currItem->itemText.applyCharStyle(0, currItem->itemText.length(), newStyle);
 			currItem->invalid = true;
+			if (currItem->isTextFrame() && !currItem->isNoteFrame())
+			{
+				foreach (PageItem_NoteFrame* nF, currItem->asTextFrame()->notesFramesList())
+				{
+					if (nF->isEndNotesFrame())
+						continue;
+					NotesSet* nSet = nF->notesSet();
+					if (nSet->notesParStyle().isEmpty() || (nSet->notesParStyle() == tr("No Style")))
+					{
+						nF->itemText.setDefaultStyle(dstyle);
+						nF->invalid = true;
+						flag_notesChanged = true;
+					}
+				}
+			}
+			else if (currItem->isNoteFrame())
+				flag_notesChanged = true;
 		}
 		if (currItem->asPathText())
 			currItem->updatePolyClip();
+		if (currItem->isNoteFrame())
+			currItem->asNoteFrame()->updateNotesText();
 		currItem->invalidateLayout();
 	}
 	if (activeTransaction)
@@ -8555,9 +8669,15 @@ void ScribusDoc::itemSelection_SetCharStyle(const CharStyle & newStyle, Selectio
 			currItem->itemText.setDefaultStyle(dstyle);
 //			if (currItem->asPathText())
 			currItem->itemText.setCharStyle(0, currItem->itemText.length(), newStyle);
+			if (currItem->isTextFrame() && !currItem->isNoteFrame())
+				updateItemNotesFramesStyles(currItem);
+			else if (currItem->isNoteFrame())
+				flag_notesChanged = true;
 		}
 		if (currItem->asPathText())
 			currItem->updatePolyClip();
+		if (currItem->isNoteFrame())
+			currItem->asNoteFrame()->updateNotesText();
 		currItem->invalidateLayout();
 	}
 	if (activeTransaction)
@@ -8636,9 +8756,15 @@ void ScribusDoc::itemSelection_EraseCharStyle(Selection* customSelection)
 			newStyle.setParent(defStyle.charStyle().parent());
 			defStyle.charStyle() = newStyle;
 			currItem->itemText.setDefaultStyle(defStyle);
+			if (currItem->isTextFrame() && !currItem->isNoteFrame())
+				updateItemNotesFramesStyles(currItem);
+			else if (currItem->isNoteFrame())
+				flag_notesChanged = true;
 		}
 		if (currItem->asPathText())
 			currItem->updatePolyClip();
+		if (currItem->isNoteFrame())
+			currItem->asNoteFrame()->updateNotesText();
 		currItem->invalidateLayout();
 	}
 	if (activeTransaction)
@@ -10329,17 +10455,22 @@ void ScribusDoc::itemSelection_ClearItem(Selection* customSelection)
 				if ((ScCore->fileWatcher->files().contains(currItem->Pfile) != 0) && (currItem->PictureIsAvailable))
 					ScCore->fileWatcher->removeFile(currItem->Pfile);
 			}
-			else
-			if (currItem->asTextFrame() && ScCore->usingGUI())
+			else if (currItem->asTextFrame())
 			{
-				if (currItem->itemText.length() != 0 && (currItem->nextInChain() == 0 || currItem->prevInChain() == 0))
+				if (ScCore->usingGUI())
 				{
-					int t = ScMessageBox::warning(m_ScMW, CommonStrings::trWarning,
-										tr("Do you really want to clear all your text?"),
-										QMessageBox::Yes, QMessageBox::No | QMessageBox::Default);
-					if (t == QMessageBox::No)
-						continue;
+					if (currItem->itemText.length() != 0 && (currItem->nextInChain() == 0 || currItem->prevInChain() == 0))
+					{
+						int t = ScMessageBox::warning(m_ScMW, CommonStrings::trWarning,
+													  tr("Do you really want to clear all your text?"),
+													  QMessageBox::Yes, QMessageBox::No | QMessageBox::Default);
+						if (t == QMessageBox::No)
+							continue;
+					}
 				}
+				//remove marks - with GUI ask user if he knows that marks are in text and were deleted
+				if (!currItem->asTextFrame()->removeMarksFromText(!hasGUI()))
+					continue;
 			}
 			currItem->clearContents();
 		}
@@ -10454,11 +10585,29 @@ void ScribusDoc::itemSelection_DeleteItem(Selection* customSelection, bool force
 		currItem = delItems.at(selectedItemCount - (de + 1));
 		if ((currItem->asImageFrame()) && ((ScCore->fileWatcher->files().contains(currItem->Pfile) != 0) && (currItem->PictureIsAvailable)))
 			ScCore->fileWatcher->removeFile(currItem->Pfile);
-		if (currItem->asTextFrame())
+		//delete marks pointed to that item
+		for (int a=0; a < m_docMarksList.count(); a++)
+		{
+			Mark* m = m_docMarksList.at(a);
+			if (m == NULL)
+				continue;
+			if (m->isType(MARK2ItemType) && (m->getItemPtr() == currItem))
+				eraseMark(m, true);
+		}
+		if (currItem->isNoteFrame())
+			delNoteFrame(currItem->asNoteFrame());
+		else
 		{
-			currItem->dropLinks();
-			
-			/* this code will instead remove the contained text
+			if (currItem->asTextFrame())
+			{
+				//delete all note`s frame created for that text frame
+				//force deleting all notes frames
+				if (!currItem->asTextFrame()->isInChain() && !currItem->asTextFrame()->removeMarksFromText(!hasGUI()))
+					//frame isn`t in text chain - user decides to not deleting notes
+					continue;
+				currItem->asTextFrame()->delAllNoteFrames(false);
+				currItem->dropLinks();
+				/* this code will instead remove the contained text
 			// unlink after
 			currItem->unlink();
 			if (before != 0)
@@ -10472,24 +10621,26 @@ void ScribusDoc::itemSelection_DeleteItem(Selection* customSelection, bool force
 				}
 			}
 			*/
+			}
+			if (currItem->isWelded())
+				currItem->unWeld();
+			if (currItem->isBookmark)
+				//CB From view   emit DelBM(currItem);
+				m_ScMW->DelBookMark(currItem);
+			if (UndoManager::undoEnabled() && (selectedItemCount > 0) && !forceDeletion)
+			{
+				ScItemState< QList<PageItem*> > *is = new ScItemState< QList<PageItem*> >(Um::Delete + " " + currItem->getUName(), "", Um::IDelete);
+				is->setItem(delItems);
+				is->set("ITEMID", itemList->indexOf(currItem));
+				is->set("DELETE_ITEM", "delete_item");
+				undoManager->action(Pages->at(0), is, currItem->getUPixmap());
+			}
+			//FIX ME - itemList->removeOne will not be suitable and faster?
+			itemList->removeAll(currItem);
+			//		if (forceDeletion || !UndoManager::undoEnabled())
+			if (forceDeletion)
+				delete currItem;
 		}
-		if (currItem->isWelded())
-			currItem->unWeld();
-		if (currItem->isBookmark)
-			//CB From view   emit DelBM(currItem);
-			m_ScMW->DelBookMark(currItem);
-		if (UndoManager::undoEnabled() && (selectedItemCount > 0) && !forceDeletion)
-		{
-			ScItemState< QList<PageItem*> > *is = new ScItemState< QList<PageItem*> >(Um::Delete + " " + currItem->getUName(), "", Um::IDelete);
-			is->setItem(delItems);
-			is->set("ITEMID", itemList->indexOf(currItem));
-			is->set("DELETE_ITEM", "delete_item");
-			undoManager->action(Pages->at(0), is, currItem->getUPixmap());
-		}
-		itemList->removeAll(currItem);
-//		if (forceDeletion || !UndoManager::undoEnabled())
-		if (forceDeletion)
-			delete currItem;
 	}
 	itemSelection->delaySignalsOff();
 	if (activeTransaction)
@@ -15054,7 +15205,7 @@ QMap<PageItem*, QString> ScribusDoc::getDocItemNames(PageItem::ItemType itemType
 Serializer *ScribusDoc::serializer()
 {
 	if (!m_serializer) 
-		m_serializer = new Serializer (*this);
+		m_serializer = new Serializer (this);
 	Q_ASSERT(m_serializer);
 	return m_serializer;
 }
@@ -15333,3 +15484,1168 @@ int ScribusDoc::addToInlineFrames(PageItem *item)
 	FrameItems.insert(fIndex, item);
 	return fIndex;
 }
+
+QStringList ScribusDoc::marksLabelsList(MarkType type)
+{
+	QStringList nameList;
+	for (int a=0; a < m_docMarksList.count(); ++a)
+	{
+		Mark* m = m_docMarksList.at(a);
+		if (m == NULL)
+			continue;
+		if ((m != NULL) && m->isType(type))
+			nameList.append(m->label);
+	}
+	return nameList;
+}
+
+Mark* ScribusDoc::getMarkDefinied(QString l, MarkType t)
+{
+	foreach (Mark* mrk, m_docMarksList)
+	{
+		if ((mrk != NULL) && (mrk->label == l) && mrk->isType(t))
+			return mrk;
+	}
+	return NULL;
+}
+
+PageItem* ScribusDoc::findMark(Mark* mrk, int &lastItem)
+{
+	//except marks to items, in itemPtr should be item which holds this mark
+	PageItem* item = NULL;
+	if (!mrk->isType(MARK2ItemType) && (lastItem == -1))
+	{
+		item = getItemFromName(mrk->getItemName());
+		if (item != NULL)
+		{
+			int Cpos = -1;
+			if (findMarkCPos(mrk, item, Cpos))
+			{
+				lastItem = DocItems.indexOf(item);
+				return item;
+			}
+		}
+	}
+	for (int a = lastItem +1; a < DocItems.count(); ++a)
+	{
+		item = DocItems.at(a);
+		if ((item != NULL) && item->isTextFrame() && (item->itemText.length() > 0))
+		{
+			for (int i = item->firstInFrame(); i <= item->lastInFrame(); ++i)
+			{
+				ScText* hl = item->itemText.item(i);
+				if (hl->hasMark(mrk))
+				{
+					lastItem = a;
+					return item;
+				}
+			}
+		}
+	}
+	lastItem = 0;
+	return NULL;
+}
+
+bool ScribusDoc::findMarkCPos(Mark* mrk, PageItem* &currItem, int &pos)
+{
+	if (currItem == NULL)
+		currItem = findMark(mrk);
+	if ((currItem != NULL) && currItem->isTextFrame() && (currItem->itemText.length() > 0))
+	{
+		for (pos = qMax(pos, currItem->firstInFrame()); pos <= currItem->lastInFrame(); ++pos)
+		{
+			ScText* hl = currItem->itemText.item(pos);
+			if (hl->hasMark(mrk))
+				return true;
+		}
+	}
+	pos = -1;
+	return false;
+}
+
+bool ScribusDoc::isMarkUsed(Mark* mrk, bool visible)
+{
+	foreach (PageItem* currItem, DocItems)
+	{
+		if (currItem->isTextFrame() && (currItem->itemText.length() > 0))
+		{
+			if (!visible && currItem->prevInChain() != NULL)
+				//check in whole itemText only for first frames in chain
+				continue;
+			int i = 0;
+			int end = currItem->itemText.length();
+			if (visible)
+			{
+				//search only in visible text
+				i = currItem->firstInFrame();
+				end = currItem->lastInFrame() +1;
+			}
+			for (; i < end; ++i)
+			{
+				ScText* hl = currItem->itemText.item(i);
+				if (hl->hasMark(mrk))
+					return true;
+			}
+		}
+	}
+	return false;
+}
+
+void ScribusDoc::setCursor2MarkPos(Mark *mark)
+{
+	if (mark == NULL)
+		return;
+	PageItem* item = NULL;
+	if (mark->isType(MARKNoteFrameType) || mark->isType(MARKNoteMasterType))
+		item = mark->getItemPtr();
+	if (item == NULL)
+		item = getItemFromName(mark->getItemName());
+	if (item == NULL)
+		item = findMark(mark);
+	if (item == NULL)
+		return;
+
+	int CPos = item->firstInFrame();
+	if (findMarkCPos(mark, item, CPos))
+	{
+		scMW()->deselectAll();
+		scMW()->selectItemFromOutlines(item, true, CPos +1);
+	}
+}
+
+bool ScribusDoc::eraseMark(Mark *mrk, bool fromText, PageItem *item)
+{
+	bool found = false;
+	if (item != NULL)
+	{
+		int MPos = -1;
+		while (findMarkCPos(mrk, item, MPos))
+		{
+			item->itemText.item(MPos)->mark = NULL;
+			if (fromText)
+				item->itemText.removeChars(MPos,1);
+				found = true;
+		}
+	}
+	else
+	{
+		//find and delete all mark`s apperences in text
+		int MPos = -1;
+		int itemIndex = -1;
+		PageItem* item = findMark(mrk, itemIndex);
+		while (item != NULL)
+		{
+			while (findMarkCPos(mrk, item, MPos))
+			{
+				item->itemText.item(MPos)->mark = NULL;
+				if (fromText)
+					item->itemText.removeChars(MPos,1);
+			}
+			found = true;
+			item->asTextFrame()->invalidateLayout();
+			item = findMark(mrk, itemIndex);
+		}
+	}
+	//remove mark references
+	for (int a=0; a < m_docMarksList.count(); ++a)
+	{
+		Mark* m = m_docMarksList.at(a);
+		if (m == NULL)
+			continue;
+		if (m->isType(MARK2MarkType))
+		{
+			QString l;
+			MarkType t;
+			m->getMark(l, t);
+			if (mrk == getMarkDefinied(l, t))
+			{
+				m->setMark(NULL);
+				m->setString("");
+			}
+		}
+	}
+	//erase mark from marksMap
+	m_docMarksList.removeOne(mrk);
+	delete mrk;
+	return found;
+}
+
+bool ScribusDoc::invalidateMarkMasterText(Mark* mrk, bool forceUpdate)
+{
+	int itemNo = -1;
+	bool found = false;
+	PageItem* mItem = findMark(mrk, itemNo);
+	while (mItem != NULL)
+	{
+		found = true;
+		mItem->asTextFrame()->invalidateLayout();
+		if (forceUpdate)
+			mItem->layout();
+		mItem = findMark(mrk, itemNo);
+	}
+	return found;
+}
+
+//update strings (page number) for marks pointed to anchors and items
+//and update marks list in Marka Manager
+bool ScribusDoc::updateMarks(bool updateNotesMarks)
+{
+	if (m_docMarksList.isEmpty())
+		return false;
+	m_docMarksList.removeAll(NULL);
+
+	bool docWasChanged = false;
+
+	//run for variable text (invalidate frames with variable text)
+	foreach (Mark* mrk, m_docMarksList)
+	{
+		if (mrk->isType(MARKVariableTextType))
+		{
+			if (invalidateMarkMasterText(mrk, false))
+				docWasChanged = true;
+		}
+		else if (mrk->isUnique())
+		{
+			PageItem* mItem = findMark(mrk);
+			mrk->OwnPage =(mItem != NULL) ? mItem->OwnPage : -1;
+			mrk->setItemName((mItem != NULL) ? mItem->itemName() : "");
+		}
+	}
+
+	//update marks for foot/endnotes
+	if (updateNotesMarks)
+	{
+		//update notes numbers
+		for (int i=0; i < m_docNotesSetsList.count(); ++i)
+		{
+			NotesSet* NS = m_docNotesSetsList.at(i);
+			//update nums
+			if (updateNotesNums(NS))
+			{
+				//refresh endnotes content
+				if (flag_updateEndNotes || isLoading())
+					updateEndnotesFrames(NS);
+				docWasChanged = true;
+			}
+			if (flag_updateEndNotes)
+				updateEndnotesFrames(NS);
+			updateNotesFramesStyles(NS);
+		}
+		notesFramesUpdate();
+	}
+
+	//for all marks
+	foreach (Mark* mrk, m_docMarksList)
+	{
+		//set mark page number
+		PageItem* mItem = findMark(mrk);
+		if (mItem != NULL)
+			mrk->OwnPage = mItem->OwnPage;
+		else
+			mrk->OwnPage = -1;
+		if (mrk->isType(MARK2ItemType))
+		{
+			if (mrk->getItemPtr() != NULL)
+			{
+				int page = mrk->getItemPtr()->OwnPage +1;
+				if (mrk->getString().toInt() != page)
+				{
+					mrk->setString(QString("%1").arg(page));
+					if (mItem != NULL)
+					{
+						mItem->asTextFrame()->invalidateLayout();
+						docWasChanged = true;
+					}
+				}
+			}
+			else
+				mrk->setString("");
+		}
+		else if (mrk->isType(MARK2MarkType))
+		{
+			QString l;
+			MarkType t;
+			mrk->getMark(l,t);
+			Mark* destMark = getMarkDefinied(l,t);
+			if (destMark != NULL)
+			{
+				PageItem* dItem = findMark(destMark);
+				if (dItem == NULL)
+				{
+					destMark->OwnPage = -1;
+					mrk->setString("");
+					docWasChanged = true;
+				}
+				else
+				{
+					destMark->OwnPage = dItem->OwnPage;
+					int page = destMark->OwnPage +1;
+					if (mrk->getString().toInt() != page)
+					{
+						mrk->setString(QString("%1").arg(page));
+						if (mItem != NULL)
+						{
+							mItem->asTextFrame()->invalidateLayout();
+							docWasChanged = true;
+						}
+					}
+				}
+			}
+			else
+			{
+				mrk->setString("");
+				docWasChanged = true;
+			}
+		}
+	}
+	return docWasChanged;
+}
+
+NotesSet* ScribusDoc::newNotesSet(NotesSet NS)
+{
+	QString nsName = NS.name();
+
+	//if doc is loading overwrite current set
+	NotesSet* newNS = getNS(nsName);
+	if (isLoading() && (newNS != NULL))
+		*newNS = NS;
+	else
+	{
+		//add new notes set
+		if (!validateNSet(NS))
+			return NULL;
+		newNS = new NotesSet();
+		*newNS = NS;
+		QStringList nsNames;
+		for (int a = 0; a< m_docNotesSetsList.count(); ++a)
+			nsNames.append(m_docNotesSetsList.at(a)->name());
+		getUniqueName(nsName, nsNames, "_");
+		newNS->setName(nsName);
+		m_docNotesSetsList.append(newNS);
+	}
+	return newNS;
+}
+
+void ScribusDoc::renameNotesSet(NotesSet* NS, QString newName)
+{
+	foreach (Mark* mrk, m_docMarksList)
+		mrk->label.replace("_" + NS->name()+ "_", "_" + newName + "_");
+	NS->setName(newName);
+}
+
+void ScribusDoc::deleteNoteSet(QString nsName)
+{
+	NotesSet* NS = getNS(nsName);
+	assert(NS != NULL);
+	//do not delete default notes set
+	if (NS == m_docNotesSetsList.at(0))
+		return;
+	
+	QList<TextNote*> toDel;
+	//search for notes to deleting
+	foreach (TextNote* note, m_docNotesList)
+	{
+		if (note->notesSet() == NS)
+			toDel.append(note);
+	}
+	//deleting notes
+	if (!toDel.isEmpty())
+	{
+		while (!toDel.isEmpty())
+			deleteNote(toDel.takeFirst(), true);
+	}
+	notesFramesUpdate();
+	m_docNotesSetsList.removeOne(NS);
+	delete NS;
+	flag_updateNotesLabels = true;
+	flag_updateEndNotes = true;
+}
+
+NotesSet* ScribusDoc::getNS(QString nsName)
+{
+	for (int a=0; a < m_docNotesSetsList.count(); ++a)
+	{
+		if (m_docNotesSetsList.at(a)->name() == nsName)
+			return m_docNotesSetsList.at(a);
+	}
+	return NULL;
+}
+
+void ScribusDoc::deleteNote(TextNote* note, bool fromText)
+{
+	if (note == NULL)
+		return;
+	PageItem_NoteFrame* nF = NULL;
+	if (note->noteMark() != NULL)
+		if (note->noteMark()->getItemPtr() != NULL)
+			nF = note->noteMark()->getItemPtr()->asNoteFrame();
+	if (nF == NULL)
+		nF = findMark(note->noteMark())->asNoteFrame();
+	Q_ASSERT(nF != NULL);
+	nF->removeNote(note);
+	if (note->masterMark() != NULL)
+		eraseMark(note->masterMark(), fromText);
+	if (note->noteMark() != NULL)
+		eraseMark(note->noteMark(), fromText);
+	m_docNotesList.removeOne(note);
+	delete note;
+	flag_notesChanged = true;
+}
+
+void ScribusDoc::updateItemNotesNums(PageItem_TextFrame* frame, NotesSet* nSet, int &num)
+{
+	//update marks strings in master text and in notes frame (only numbers!)
+	//check if notes schould be added or removed from notes frame
+	int noteNum = num;
+	ScText* hl;
+	int index = 0;
+	bool doUpdate = false;
+
+	for (int pos = frame->firstInFrame(); pos <= frame->lastInFrame(); ++pos)
+	{
+		hl = frame->itemText.item(pos);
+		if (hl->hasMark() && hl->mark->isType(MARKNoteMasterType))
+		{
+			if (hl->mark->getNotePtr() == NULL)
+				continue;
+			if (hl->mark->getNotePtr()->notesSet() == nSet)
+			{
+				QString numStr = nSet->prefix() + nSet->numString(noteNum) + nSet->suffix();
+				QString mStr = hl->mark->getString();
+				QString label = hl->mark->label;
+				if ((mStr != numStr) || flag_updateNotesLabels || flag_updateEndNotes)
+				{
+					doUpdate = true;
+					hl->mark->setString(numStr);
+					label = "NoteMark_" + nSet->name();
+					if (nSet->range() != NSRdocument)
+					{
+						if (nSet->range() == NSRsection)
+							label += " in section " + getSectionNameForPageIndex(frame->OwnPage) + " page " + QString::number(frame->OwnPage +1);
+						else if (nSet->range() == NSRpage)
+							label += " on page " + QString::number(frame->OwnPage +1);
+						else if (nSet->range() == NSRstory)
+							label += " in " + frame->firstInChain()->itemName();
+						else if (nSet->range() == NSRframe)
+							label += " in frame " + frame->itemName();
+					}
+					label += "_" + QString::number(noteNum);
+					hl->mark->label = label;
+				}
+				TextNote* note = hl->mark->getNotePtr();
+				note->setNum(noteNum);
+				note->masterMark()->setItemPtr(frame);
+				if (note->noteMark() != NULL)
+				{
+					note->noteMark()->setString(numStr);
+					label = label.replace("NoteMark","NoteFrameMark");
+					note->noteMark()->label = label;
+				}
+				++index;
+				++noteNum;
+			}
+		}
+	}
+	PageItem_NoteFrame * nF;
+	if (nSet->isEndNotes())
+		nF = endNoteFrame(nSet);
+	else
+		nF = frame->itemNoteFrame(nSet);
+
+	if (doUpdate)
+	{
+		frame->invalidateLayout();
+		if (nF != NULL)
+		{
+			if (nSet->isEndNotes())
+				m_docEndNoteFrameChanged.append(nF);
+			else if (!nF->deleteIt)
+				nF->invalidateLayout(true);
+		}
+	}
+	num = noteNum;
+	if (!nSet->isEndNotes() && (index == 0) && (nF != NULL))
+		nF->deleteIt = true;
+}
+
+bool ScribusDoc::updateNotesNums(NotesSet *nSet)
+{
+	bool docWasChanged = false;
+	flag_restartMarksRenumbering = false;
+	flag_updateEndNotes = false;
+	PageItem_NoteFrame* endNF = NULL;
+	if (nSet->isEndNotes() && nSet->range() == NSRdocument)
+	{
+		endNF = endNoteFrame(nSet);
+		if (endNF != NULL)
+			clearNotesInFrameList(endNF);
+	}
+	flag_layoutNotesFrames = false;  //do not layout notes frames while counting notes
+	int num, i;
+	int itemsCount = Items->count();
+	if ((nSet->range() == NSRdocument) || ((nSet->range() == NSRsection) && docPrefsData.docSectionMap.isEmpty()))
+	{
+		//FIX ME: how to change frames order on page? and what about reverse page order?
+		num = nSet->start();
+		for (int page = 0; page < Pages->count(); ++page)
+		{
+			for (i = 0; i < itemsCount; ++i)
+			{
+				PageItem* currItem = Items->at(i);
+				if ((currItem->OwnPage == page) && currItem->isTextFrame() && !currItem->isNoteFrame() && (currItem->itemText.length() > 0))
+				{
+					if (!currItem->asTextFrame()->isValidChainFromBegin())
+					{
+						currItem->layout();
+						if (flag_restartMarksRenumbering)
+						{
+							//restart whole update as items was changed
+							if (endNF != NULL)
+								clearNotesInFrameList(endNF);
+							page = -1;
+							i = -1;
+							itemsCount = Items->count();
+							num = nSet->start();
+							docWasChanged = true;
+							flag_restartMarksRenumbering = false;
+							break;
+						}
+					}
+					if (nSet->isEndNotes() || currItem->asTextFrame()->hasNoteFrame(nSet, false))
+						updateItemNotesNums(currItem->asTextFrame(), nSet, num);
+					if (currItem->asTextFrame()->hasNoteFrame(nSet, false) && currItem->asTextFrame()->itemNoteFrame(nSet)->invalid)
+						docWasChanged = true;
+					if (currItem->invalid)
+					{
+						currItem->layout();
+						docWasChanged = true;
+					}
+				}
+			}
+		}
+		if ((num == nSet->start()) && nSet->isEndNotes())
+		{
+			PageItem_NoteFrame* nF = endNoteFrame(nSet);
+			if (nF != NULL)
+				nF->deleteIt = true;
+		}
+	}
+	else if (nSet->range() == NSRsection)
+	{
+		Q_ASSERT(!docPrefsData.docSectionMap.isEmpty());
+		foreach (DocumentSection section, docPrefsData.docSectionMap.values())
+		{
+			num = nSet->start();
+			for (int page = section.fromindex; page <= (int) section.toindex ; ++page)
+			{
+				if (nSet->isEndNotes())
+				{
+					endNF = endNoteFrame(nSet, getSectionKeyForPageIndex(page));
+					if (endNF != NULL)
+						clearNotesInFrameList(endNF);
+				}
+				for (i = 0; i < itemsCount; ++i)
+				{
+					PageItem* currItem = Items->at(i);
+					if (currItem == NULL)
+						continue;
+					if ((currItem->OwnPage == page) && currItem->isTextFrame() && !currItem->isNoteFrame() && (currItem->itemText.length() > 0))
+					{
+						if (!currItem->asTextFrame()->isValidChainFromBegin())
+						{
+							currItem->layout();
+							if (flag_restartMarksRenumbering)
+							{
+								//restart whole update as items was changed
+								if (endNF != NULL)
+									clearNotesInFrameList(endNF);
+								page = section.fromindex -1;
+								i = -1;
+								itemsCount = Items->count();
+								num = nSet->start();
+								docWasChanged = true;
+								flag_restartMarksRenumbering = false;
+								break;
+							}
+						}
+						if (nSet->isEndNotes() || currItem->asTextFrame()->hasNoteFrame(nSet, false))
+							updateItemNotesNums(currItem->asTextFrame(), nSet, num);
+						if (currItem->asTextFrame()->hasNoteFrame(nSet, false) && currItem->asTextFrame()->itemNoteFrame(nSet)->invalid)
+							docWasChanged = true;
+						if (currItem->invalid)
+						{
+							currItem->layout();
+							docWasChanged = true;
+						}
+					}
+				}
+				if ((i != -1) && (num == nSet->start()) && nSet->isEndNotes())
+				{
+					PageItem_NoteFrame* nF = endNoteFrame(nSet);
+					if (nF != NULL)
+						nF->deleteIt = true;
+				}
+			}
+		}
+	}
+	else if (nSet->range() == NSRstory || nSet->range() == NSRframe)
+	{
+		for (i = 0; i < itemsCount; ++i)
+		{
+			PageItem* currItem = Items->at(i);
+			if (currItem == NULL)
+				continue;
+			if (currItem->isTextFrame() && !currItem->isNoteFrame() && (currItem->itemText.length() > 0))
+			{
+				if (nSet->isEndNotes() && nSet->range() == NSRstory)
+				{
+					endNF = endNoteFrame(nSet, (void*) currItem);
+					if (endNF != NULL)
+						clearNotesInFrameList(endNF);
+				}
+				if (!currItem->asTextFrame()->isValidChainFromBegin())
+				{
+					currItem->layout();
+					if (flag_restartMarksRenumbering)
+					{
+						//restart whole update as items was changed
+						if (endNF != NULL)
+							clearNotesInFrameList(endNF);
+						i = -1;
+						itemsCount = Items->count();
+						docWasChanged = true;
+						flag_restartMarksRenumbering = false;
+						continue;
+					}
+				}
+				if (nSet->range() == NSRstory)
+				{
+					//restart numeration for all first frames of story chain
+					if (currItem->prevInChain() == NULL)
+					{
+						num = nSet->start();
+						PageItem* nextItem = currItem;
+						while (nextItem != NULL)
+						{
+							if (nSet->isEndNotes() || nextItem->asTextFrame()->hasNoteFrame(nSet, false))
+								updateItemNotesNums(nextItem->asTextFrame(), nSet, num);
+							nextItem = nextItem->nextInChain();
+						}
+					}
+				}
+				else	//restart numeration for each frame
+				{
+					num = nSet->start();
+					if (nSet->isEndNotes() || currItem->asTextFrame()->hasNoteFrame(nSet, false))
+						updateItemNotesNums(currItem->asTextFrame(), nSet, num);
+				}
+				if (currItem->asTextFrame()->hasNoteFrame(nSet, false) && currItem->asTextFrame()->itemNoteFrame(nSet)->invalid)
+					docWasChanged = true;
+				if (currItem->invalid)
+				{
+					currItem->layout();
+					docWasChanged = true;
+				}
+			}
+		}
+	}
+	else if (nSet->range() == NSRpage)
+	{
+		for (int page = 0; page < Pages->count(); ++page)
+		{
+			if (nSet->isEndNotes() && nSet->range() == NSRpage)
+			{
+				endNF = endNoteFrame(nSet, (void*) DocPages.at(page));
+				if (endNF != NULL)
+					clearNotesInFrameList(endNF);
+			}
+			//restart numeration for each page
+			num = nSet->start();
+
+			for (i = 0; i < itemsCount; ++i)
+			{
+				PageItem* currItem = Items->at(i);
+				if (currItem == NULL)
+					continue;
+				if ((currItem->OwnPage == page) && currItem->isTextFrame() && !currItem->isNoteFrame() && (currItem->itemText.length() > 0))
+				{
+					if (!currItem->asTextFrame()->isValidChainFromBegin())
+					{
+						currItem->layout();
+						if (flag_restartMarksRenumbering)
+						{
+							//restart whole update as items was changed
+							if (endNF != NULL)
+								clearNotesInFrameList(endNF);
+							page = -1;
+							i = -1;
+							itemsCount = Items->count();
+							num = nSet->start();
+							docWasChanged = true;
+							flag_restartMarksRenumbering = false;
+							break;
+						}
+					}
+					if (nSet->isEndNotes() || currItem->asTextFrame()->hasNoteFrame(nSet, false))
+						updateItemNotesNums(currItem->asTextFrame(), nSet, num);
+					if (currItem->asTextFrame()->hasNoteFrame(nSet, false) && currItem->asTextFrame()->itemNoteFrame(nSet)->invalid)
+						docWasChanged = true;
+					if (currItem->invalid)
+					{
+						currItem->layout();
+						docWasChanged = true;
+					}
+				}
+			}
+			if ((i != -1) && (num == nSet->start()) && nSet->isEndNotes())
+			{
+				PageItem_NoteFrame* nF = endNoteFrame(nSet);
+				if (nF != NULL)
+					nF->deleteIt = true;
+			}
+		}
+	}
+	flag_layoutNotesFrames = true;
+	return docWasChanged;
+}
+
+bool ScribusDoc::updateEndNotesNums()
+{
+	bool docWasChange = false;
+	foreach (NotesSet* ns, m_docNotesSetsList)
+	{
+		if (ns->isEndNotes())
+		{
+			if (updateNotesNums(ns))
+				docWasChange = true;
+		}
+	}
+	return docWasChange;
+}
+
+void ScribusDoc::updateNotesFramesStyles(NotesSet *nSet)
+{
+	for (int i=0; i<Items->count(); ++i)
+	{
+		PageItem* item = Items->at(i);
+		if (item->isNoteFrame() && (item->asNoteFrame()->notesSet() == nSet) && !item->asNoteFrame()->deleteIt)
+		{
+			ParagraphStyle newStyle;
+			if (nSet->notesParStyle().isEmpty() || (nSet->notesParStyle() == tr("No Style")))
+			{
+				if (nSet->isEndNotes())
+					//set default doc style
+					newStyle.setParent(paragraphStyles()[0].name());
+				else
+				{
+					if (item->asNoteFrame()->masterFrame() != NULL)
+					{
+						//set back style from master frame
+						newStyle.setParent(item->asNoteFrame()->masterFrame()->itemText.defaultStyle().parent());
+						newStyle.applyStyle(item->asNoteFrame()->masterFrame()->currentStyle());
+					}
+					else
+						newStyle.setParent(item->itemText.defaultStyle().parent());
+				}
+			}
+			else
+				newStyle.setParent(nSet->notesParStyle());
+			item->itemText.setDefaultStyle(newStyle);
+			item->asTextFrame()->invalidateLayout(true);
+		}
+	}
+}
+
+void ScribusDoc::updateItemNotesFramesStyles(PageItem* item)
+{
+	if (item->isTextFrame() && !item->isNoteFrame())
+	{
+		item = item->firstInChain();
+
+		while (item != NULL)
+		{
+			foreach (PageItem_NoteFrame* nF, item->asTextFrame()->notesFramesList())
+			{
+				NotesSet* nSet = nF->notesSet();
+				ParagraphStyle newStyle;
+				if (nSet->notesParStyle().isEmpty() || (nSet->notesParStyle() == tr("No Style")))
+				{
+					if (nSet->isEndNotes())
+						//set default doc style
+						newStyle.setParent(paragraphStyles()[0].name());
+					else
+					{
+						//set back style from master frame
+						newStyle.setParent(item->itemText.defaultStyle().parent());
+						newStyle.applyStyle(item->currentStyle());
+					}
+				}
+				else
+					newStyle.setParent(nSet->notesParStyle());
+				nF->itemText.setDefaultStyle(newStyle);
+				flag_notesChanged = true;
+			}
+			item = item->nextInChain();
+		}
+	}
+}
+
+QList<PageItem_NoteFrame *> ScribusDoc::listNotesFrames(NotesSet *NS)
+{
+	QList<PageItem_NoteFrame *> list;
+	foreach(PageItem* item, DocItems)
+	{
+		if (item->isNoteFrame() && item->asNoteFrame()->notesSet() == NS)
+			list.append(item->asNoteFrame());
+	}
+	return list;
+}
+
+const ScPage *ScribusDoc::page4EndNotes(NotesSet *NS, PageItem* item)
+{
+	ScPage* scP = NULL;
+	if ((NS->range() == NSRdocument) || ((NS->range() == NSRsection) && docPrefsData.docSectionMap.isEmpty()))
+		scP = DocPages.last();
+	else if (item != NULL)
+	{
+		if (NS->range() == NSRpage)
+			scP = DocPages.at(item->OwnPage);
+		else if (NS->range() == NSRsection)
+		{
+			int section = getSectionKeyForPageIndex(item->OwnPage);
+			DocumentSection sec = sections().find(section).value();
+			scP = DocPages.at(sec.toindex);
+		}
+		else if (NS->range() == NSRstory)
+			scP = DocPages.at(item->lastInChain()->OwnPage);
+	}
+
+	return scP;
+}
+
+void ScribusDoc::notesFramesUpdate()
+{
+	bool removeEmptyNF = false;
+	int end;
+	do {
+		flag_notesChanged = false;
+		end = Items->count();
+		for (int i = 0; i < end; ++i)
+		{
+			PageItem* item = Items->at(i);
+			if (!item->isTextFrame())
+				continue;
+			if (item->isNoteFrame())
+			{
+				 if (item->asNoteFrame()->isEndNotesFrame())
+					//update content and move endnotes if pages were removed
+					updateEndNotesFrameContent(item->asNoteFrame());
+				 if (!item->asNoteFrame()->deleteIt)
+				{
+					 if (item->asNoteFrame()->masterFrame() != NULL)
+					 {
+						 //updayte styles for endnotes
+						 item->asNoteFrame()->masterFrame()->layout();
+					 }
+					 item->invalid = true;
+					 item->layout();
+				 }
+				 else
+					removeEmptyNF = true;
+			}
+			else if (item->asTextFrame()->hasNoteFrame(NULL, true))
+				item->layout();
+			if (end != Items->count())
+				flag_notesChanged = true;
+			if (flag_notesChanged)
+				break;
+		}
+	} while (flag_notesChanged);
+
+	if (removeEmptyNF)
+	{
+		end = Items->count();
+		QList<PageItem*> tmplist;
+		for (int i = 0; i < end; ++i)
+		{
+			PageItem* item = Items->at(i);
+			if (item->isNoteFrame() && item->asNoteFrame()->deleteIt)
+				tmplist.append(item);
+		}
+		foreach (PageItem* item, tmplist)
+			delNoteFrame(item->asNoteFrame());
+	}
+}
+
+void ScribusDoc::updateNotesFramesSettings(NotesSet *NS)
+{
+	foreach (PageItem_NoteFrame* nF, listNotesFrames(NS))
+	{	
+		if (nF->isWelded() && !NS->isAutoWeldNotesFrames())
+			nF->unWeld();
+		if (!nF->isWelded() && NS->isAutoWeldNotesFrames())
+		{
+			nF->setYPos(nF->masterFrame()->yPos() + nF->masterFrame()->height());
+			nF->setXPos(nF->masterFrame()->xPos());
+			nF->addWelded(nF->masterFrame());
+			nF->masterFrame()->addWelded(nF);
+			nF->masterFrame()->setWeldPoint(0, nF->masterFrame()->height(), nF);
+			nF->setWeldPoint(0,0, nF->masterFrame());
+			nF->invalidateLayout();
+		}
+		if (NS->isAutoNotesHeight() || NS->isAutoNotesWidth())
+			nF->invalidateLayout();
+	}
+}
+
+void ScribusDoc::updateEndnotesFrames(NotesSet* nSet)
+{
+	if (m_docEndNotesFramesMap.isEmpty())
+		return;
+	if (nSet == NULL)
+	{
+		int NScount = m_docNotesSetsList.count();
+		for (int i=0; i < NScount; ++i)
+			updateEndnotesFrames(m_docNotesSetsList.at(i));
+	}
+	else if (nSet->isEndNotes())
+	{
+		if (!nSet->isEndNotes())
+			return;
+		foreach (PageItem_NoteFrame* nF, listNotesFrames(nSet))
+			updateEndNotesFrameContent(nF);
+	}
+	flag_updateEndNotes = false;
+}
+
+//for sorting purpose
+bool ascendingSort(TextNote* nt1, TextNote* nt2) { return nt1->num() < nt2->num(); }
+
+void ScribusDoc::updateEndNotesFrameContent(PageItem_NoteFrame *nF)
+{
+	QList<TextNote*> nList;
+	foreach (PageItem* item, DocItems)
+	{
+		if (item->isTextFrame() && !item->isNoteFrame())
+		{
+			QList<TextNote*> nL = item->asTextFrame()->notesList(nF);
+			if (!nL.isEmpty())
+				nList.append(nL);
+		}
+	}
+
+	if (nList.isEmpty())
+	{
+		nF->deleteIt = true;
+		if (nF->itemText.length() > 0)
+			nF->itemText.clear();
+		m_docNotesInFrameMap.insert(nF, nList);
+		nF->updateNotes(nList);
+	}
+	else
+		nF->deleteIt = false;
+	PageItem* master = NULL;
+	if (!nList.isEmpty())
+		master = nList.at(0)->masterMark()->getItemPtr();
+	const ScPage* scP = page4EndNotes(nF->notesSet(), master);
+	if (scP != NULL) //move endnotes frame to its proper page
+	{
+		double x,y;
+		x = scP->Margins.Left + rulerXoffset + scP->xOffset();
+		y = scP->Margins.Top + rulerYoffset + scP->yOffset();
+		if ((scP->pageNr() != nF->OwnPage) || (nF->xPos() > (x + scP->width())) || nF->yPos() > (y + scP->height()))
+			nF->setXYPos(x,y);
+	}
+
+	NotesSet* currNS = nF->notesSet();
+	if (!nF->deleteIt && (currNS->isAutoNotesHeight() || currNS->isAutoNotesWidth()))
+		nF->invalidateLayout();
+
+	if (nList == m_docNotesInFrameMap.value(nF))
+		return;
+
+	QList<TextNote*> oldList = nF->notesList();
+	nF->updateNotes(m_docNotesInFrameMap.value(nF));
+	qSort(nList.begin(), nList.end(), ascendingSort);
+	if (nList != oldList)
+	{
+		nF->updateNotes(nList);
+//		nF->itemText.clear();
+//		while (!nList.isEmpty())
+//			nF->insertNote(tempList.takeLast());
+		nF->invalid = true;
+		nF->layout();
+		//layout all endnotes frames with same range
+		foreach (NotesSet* NS, m_docNotesSetsList)
+		{
+			if ((NS != currNS) && (NS->isEndNotes() && NS->range() == currNS->range()))
+				foreach (PageItem_NoteFrame* NF, listNotesFrames(NS))
+					NF->updateLayout();
+		}
+		m_docNotesInFrameMap.insert(nF, nList);
+	}
+}
+
+void ScribusDoc::updateChangedEndNotesFrames()
+{
+	while (!m_docEndNoteFrameChanged.isEmpty())
+	{
+		PageItem_NoteFrame* nF = m_docEndNoteFrameChanged.first();
+		m_docEndNoteFrameChanged.removeAll(nF);
+		updateEndNotesFrameContent(nF);
+		if (nF->deleteIt)
+			delNoteFrame(nF);
+	}
+}
+
+void ScribusDoc::delNoteFrame(PageItem_NoteFrame* nF, bool force)
+{
+	Q_ASSERT(nF != NULL);
+	if (nF->itemText.length() > 0)
+	{
+		nF->removeMarksFromText(true);
+		nF->itemText.clear();
+		if (appMode == modeEdit && nF->isSelected())
+		{
+			view()->Deselect(true);
+			view()->requestMode(modeNormal);
+		}
+		NotesSet* nSet = nF->notesSet();
+		if (nSet->isEndNotes())
+		{
+			m_docEndNotesFramesMap.remove(nF);
+			foreach (PageItem* item, DocItems)
+			{
+				bool hasNF = false;
+				if (item->isTextFrame() && !item->isNoteFrame())
+				{
+					hasNF = item->asTextFrame()->hasNoteFrame(nF);
+					item->asTextFrame()->delNoteFrame(nF);
+				}
+				if (hasNF)
+					item->asTextFrame()->invalidateLayout();
+			}
+		}
+		else
+		{
+			PageItem_TextFrame* master = nF->masterFrame();
+			if (master != NULL)
+			{
+				master->delNoteFrame(nF);
+				master->invalidateLayout();
+			}
+		}
+	}
+	m_docNotesInFrameMap.remove(nF);
+
+	nF->dropLinks();
+	if (nF->isWelded())
+		nF->unWeld();
+	//delete marks pointed to that item
+	//FIX ME - as notes frames are dynamic so creating marks pointed to it should be avoided
+	for (int a=0; a < m_docMarksList.count(); ++a)
+	{
+		Mark* m = m_docMarksList.at(a);
+		Q_ASSERT(m != NULL);
+		if (m->isType(MARK2ItemType) && (m->getItemPtr() == nF))
+			m->setItemPtr(NULL);
+	}
+	if (Items->removeOne(nF))
+	{
+		flag_notesChanged = true;
+		delete nF;
+	}
+}
+
+bool ScribusDoc::validateNSet(NotesSet NS, QString newName)
+{
+	//check if choosen numbering type is avaiable with choosen range, prefix and suffix
+	QString errStr = QString();
+	foreach (NotesSet* NS2, m_docNotesSetsList)
+	{
+		if (newName.isEmpty())
+			//hack for validate nset while its name will change
+			newName = NS.name();
+		if (newName == NS2->name())
+			continue;
+		if (NS.range() == NS2->range())
+		{
+				if ((NS.getType() == NS2->getType()) && (NS.prefix() == NS2->prefix()) && (NS.suffix() == NS2->suffix()))
+					errStr.append(NS.name() + tr("Notes set has document as range and provide same numbering style as set ") + NS2->name() + "\n");
+		}
+	}
+
+	if (!errStr.isEmpty() && ScCore->usingGUI())
+	{
+		ScMessageBox::warning(this->scMW(), QObject::tr("Unaceptable settings for Notes Set"), "<qt>"+ errStr +"</qt>", QMessageBox::Ok, QMessageBox::Abort | QMessageBox::Default);
+		return false;
+	}
+	return true;
+}
+
+void ScribusDoc::invalidateNoteFrames(NotesSet *nSet)
+{
+	foreach (PageItem_NoteFrame* nF, listNotesFrames(nSet))
+		nF->invalid = true;
+}
+
+PageItem_NoteFrame *ScribusDoc::endNoteFrame(NotesSet *nSet, PageItem_TextFrame *master)
+{
+	if (nSet->range() == NSRdocument)
+		return endNoteFrame(nSet);
+	else if (nSet->range() == NSRsection)
+		return endNoteFrame(nSet, getSectionKeyForPageIndex(master->OwnPage));
+	else if (nSet->range() == NSRpage)
+		return endNoteFrame(nSet, (void*) DocPages.at(master->OwnPage));
+	else if (nSet->range() == NSRstory)
+		return endNoteFrame(nSet, master->firstInChain());
+	return NULL;
+}
+
+PageItem_NoteFrame* ScribusDoc::endNoteFrame(NotesSet *nSet, int sectIndex)
+{
+	if (nSet->range() != NSRsection)
+		return NULL;
+	if (m_docEndNotesFramesMap.isEmpty())
+		return NULL;
+
+	QMap<PageItem_NoteFrame*, rangeItem>::Iterator it = m_docEndNotesFramesMap.begin();
+	QMap<PageItem_NoteFrame*, rangeItem>::Iterator end = m_docEndNotesFramesMap.end();
+	while (it != end)
+	{
+		PageItem_NoteFrame* nF = it.key();
+		if (nF->notesSet() == nSet)
+		{
+			rangeItem rItem = it.value();
+			if (rItem.sectionIndex == sectIndex)
+				return nF;
+		}
+		++it;
+	}
+	return NULL;
+}
+
+PageItem_NoteFrame* ScribusDoc::endNoteFrame(NotesSet *nSet, void* item)
+{
+	if (m_docEndNotesFramesMap.isEmpty())
+		return NULL;
+	if ((nSet->range() != NSRdocument) && (item == NULL))
+		return NULL;
+
+	QMap<PageItem_NoteFrame*, rangeItem>::Iterator it = m_docEndNotesFramesMap.begin();
+	QMap<PageItem_NoteFrame*, rangeItem>::Iterator end = m_docEndNotesFramesMap.end();
+
+	while (it != end)
+	{
+		PageItem_NoteFrame* nF = it.key();
+		rangeItem rItem = it.value();
+
+		if (nF->notesSet() == nSet)
+		{
+			if ((nSet->range() == NSRdocument) || (item == rItem.P))
+				return nF;
+		}
+		++it;
+	}
+	return NULL;
+}
diff --git a/Scribus/scribus/scribusdoc.h b/Scribus/scribus/scribusdoc.h
index 34b2aba..12a51b0 100644
--- a/Scribus/scribus/scribusdoc.h
+++ b/Scribus/scribus/scribusdoc.h
@@ -41,10 +41,13 @@ for which a new license (GPL+exception) is in place.
 #include "scribusapi.h"
 #include "colormgmt/sccolormgmtengine.h"
 #include "documentinformation.h"
+#include "marks.h"
+#include "notesset.h"
 #include "observable.h"
 #include "pageitem.h"
 #include "pageitem_group.h"
 #include "pageitem_latexframe.h"
+#include "pageitem_textframe.h"
 #include "pagestructs.h"
 #include "prefsstructs.h"
 #include "scguardedptr.h"
@@ -75,8 +78,10 @@ class PageSize;
 class ScPattern;
 class UndoTransaction;
 class Serializer;
-
 class QProgressBar;
+class MarksManager;
+class NotesSet;
+class TextNote;
 
 struct SCRIBUS_API NodeEditContext : public MassObservable<QPointF>
 {
@@ -778,8 +783,9 @@ public:
 	\param w ?
 	\param fill fill color name
 	\param outline outline color name
+	\param noteFrame optional (default false) indicates that noteframes should be created, not text frame
 	*/
-	int itemAdd(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double b, const double h, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
+	int itemAdd(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double b, const double h, const double w, const QString& fill, const QString& outline, const bool itemFinalised, const bool noteFrame = false);
 
 	/** Add an item to the page based on the x/y position. Item will be fitted to the closest guides/margins */
 	int itemAddArea(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
@@ -972,6 +978,11 @@ public:
 	 * 
 	 */
 	void setFirstSectionFromFirstPageNumber();
+	/**
+	 * @param pageIndex page nr
+	 * @brief Returns name of section where page is located
+	 */
+	QString getSectionNameForPageIndex(const uint pageIndex) const;
 
 	//! @brief Some internal align tools
 	typedef enum {alignFirst, alignLast, alignPage, alignMargins, alignGuide, alignSelection } AlignTo;
@@ -1602,6 +1613,119 @@ public slots:
 	void updatePict(QString name);
 	void updatePictDir(QString name);
 	void removePict(QString name);
+
+// Marks and notes
+public:
+	/**
+	 * Explanation
+	 * master frame - text frame with marks for notes
+	 * notesframe - frame with notes
+	 * master & note mark - master is mark in "master" text, note mark is at begining of note in noteframe
+	 */
+	
+	//return page where endnotesframe should be located depending of notes set range and location of master mark
+	const ScPage* page4EndNotes(NotesSet* NS, PageItem* item);
+
+	//data handling structures
+	QList<Mark*> m_docMarksList;
+	QList<NotesSet*> m_docNotesSetsList;
+	QList<TextNote*> m_docNotesList;
+	QMap<PageItem_NoteFrame*, rangeItem> m_docEndNotesFramesMap;
+
+	//returns list of notesframes for given Notes Set
+	QList<PageItem_NoteFrame*> listNotesFrames(NotesSet* NS);
+
+	//flags used for indicating needs of updates
+	bool flag_notesChanged;
+	bool flag_restartMarksRenumbering;
+	bool flag_updateNotesLabels;
+	bool flag_updateEndNotes;
+	bool flag_layoutNotesFrames;
+
+	//returns list of marks labels for given mark type
+	QStringList marksLabelsList(MarkType type);
+
+	//return mark definied with gioven label and given type
+	Mark* getMarkDefinied(QString label, MarkType type); //returns mark with label and type (labels are unique only for same type marks)
+
+	
+	bool isMarkUsed(Mark* mrk, bool visible = false);
+	//set cursor in text where given mark will be found
+	void setCursor2MarkPos(Mark* mark);
+	//return false if mark was not found
+	bool eraseMark(Mark* mrk, bool fromText=false, PageItem* item=NULL);
+	//invalidate all text frames where given mark will found
+	//usefull spacially for varaible text marks after changing its text definition
+	//if forceUpdate then found master frames are relayouted
+	bool invalidateMarkMasterText(Mark* mrk, bool forceUpdate = false); //returns if any text was changed
+
+	//for foot/endnotes
+	NotesSet* newNotesSet(NotesSet NS);
+	void renameNotesSet(NotesSet* NS, QString newName);
+	//delete whole notes set with its notesframes and notes
+	void deleteNoteSet(QString nsName);
+	NotesSet* getNS(QString nsName);
+	//delete note, if fromText than marks for given note will be removed
+	void deleteNote(TextNote* note, bool fromText = false);
+	//delete noteframe
+	void delNoteFrame(PageItem_NoteFrame *nF, bool force=false);
+	//renumber notes for given notes set
+	//return true if doc needs update after changing numbers of notes
+	bool updateNotesNums(NotesSet* nSet);
+	//set new text styles for notes marks
+	void updateNotesFramesStyles(NotesSet* nSet);
+	//check conflicts beetween notesset
+	bool validateNSet(NotesSet NS, QString newName = "");
+	//update layout remove empty notesframes
+	void notesFramesUpdate();
+	//update notesframes after changing automatic features of notesset
+	void updateNotesFramesSettings(NotesSet* NS);
+
+	//search for endnotesframe for given notes set and item holding master mark
+	PageItem_NoteFrame* endNoteFrame(NotesSet* nSet, PageItem_TextFrame* master);
+	//
+	void setEndNoteFrame(PageItem_NoteFrame* nF, void* ptr)   { rangeItem rI={ptr}; m_docEndNotesFramesMap.insert(nF,rI); }
+	void setEndNoteFrame(PageItem_NoteFrame* nF, int section)   { rangeItem rI; rI.sectionIndex = section; m_docEndNotesFramesMap.insert(nF, rI); }
+	//update all endnotesframes content for given notes set
+	void updateEndnotesFrames(NotesSet* nSet = NULL);
+	//update endnotesframe content
+	void updateEndNotesFrameContent(PageItem_NoteFrame* nF);
+	//insert noteframe into list of changed
+	void endNoteFrameChanged(PageItem_NoteFrame* nF) { m_docEndNoteFrameChanged.append(nF); }
+	//update content for changed endnotesframes
+	void updateChangedEndNotesFrames();
+
+private:
+	QList<PageItem_NoteFrame*> m_docEndNoteFrameChanged;
+	//QMap<PageItem_NoteFrame*, QList<TextNote *> > map of notesframes and its list of notes
+	NotesInFrameMap m_docNotesInFrameMap;
+
+	//finds item which holds given mark, start searching from next to lastItem index in DocItems
+	PageItem* findMark(Mark* mrk, int &lastItem);
+	PageItem* findMark(Mark* mrk) { int tmp = -1; return findMark(mrk, tmp); }
+	//finds mark position in text
+	//return true if mark was found, CPos is set for mark`s position
+	//if item==NULL then search in all items and if mark is found than item is set
+	bool findMarkCPos(Mark* mrk, PageItem* &item, int &CPos);
+
+	//search for endnotesframe for given notes set and item holding master mark or section number
+	PageItem_NoteFrame* endNoteFrame(NotesSet* nSet, void* item = NULL);
+	PageItem_NoteFrame* endNoteFrame(NotesSet* nSet, int sectIndex);
+	//clear list of notes for given notesframe
+	void clearNotesInFrameList(PageItem_NoteFrame* nF) { m_docNotesInFrameMap.insert(nF, QList<TextNote*>()); }
+	//renumber notes with given notes set for given frame starting from number num
+	void updateItemNotesNums(PageItem_TextFrame *frame, NotesSet *nSet, int &num);
+	//update notesframes text styles
+	void updateItemNotesFramesStyles(PageItem *item);
+	
+	//not used?
+	bool updateEndNotesNums(); //return true if doc needs update
+	void invalidateNoteFrames(NotesSet* nSet);
+
+public slots:
+	//update strings (page numbers) for marks
+	bool updateMarks(bool updateNotesMarks = false);
+
 //welding two items
 public slots:
 	void itemSelection_UnWeld();
diff --git a/Scribus/scribus/scribusstructs.h b/Scribus/scribus/scribusstructs.h
index 2b4e583..e8eff8e 100644
--- a/Scribus/scribus/scribusstructs.h
+++ b/Scribus/scribus/scribusstructs.h
@@ -278,7 +278,8 @@ typedef enum {
 	FontNotEmbedded=15,
 	EmbeddedFontIsOpenType=16,
 	OffConflictLayers=17,
-	PartFilledImageFrame= 18
+	PartFilledImageFrame= 18,
+	MarksChanged = 19
 } PreflightError;
 
 typedef QMap<PreflightError, int> errorCodes;
@@ -365,6 +366,7 @@ enum UpdateRequests
 	reqCmsOptionsUpdate  = 512,
 	reqCustomShapeUpdate = 1024,
 	reqInlinePalUpdate   = 2048,
+	reqMarksUpdate       = 4096,
 	reqUpdateAll = 65535
 };
 
diff --git a/Scribus/scribus/scribusview.cpp b/Scribus/scribus/scribusview.cpp
index fa328ae..47588e5 100644
--- a/Scribus/scribus/scribusview.cpp
+++ b/Scribus/scribus/scribusview.cpp
@@ -2728,7 +2728,10 @@ QImage ScribusView::MPageToPixmap(QString name, int maxGr, bool drawFrame)
 		for (int layerLevel = 0; layerLevel < layerCount; ++layerLevel)
 		{
 			Doc->Layers.levelToLayer(layer, layerLevel);
-			m_canvas->DrawPageItems(painter, layer, QRect(clipx, clipy, clipw, cliph));
+			//two passes - first draw all except notes frames
+			m_canvas->DrawPageItems(painter, layer, QRect(clipx, clipy, clipw, cliph), false);
+			//second pass for notes frames only
+			m_canvas->DrawPageItems(painter, layer, QRect(clipx, clipy, clipw, cliph), true);
 		}
 		painter->endLayer();
 		painter->end();
@@ -2859,7 +2862,10 @@ QImage ScribusView::PageToPixmap(int Nr, int maxGr, bool drawFrame)
 			{
 				Doc->Layers.levelToLayer(layer, layerLevel);
 				m_canvas->DrawMasterItems(painter, Doc->DocPages.at(Nr), layer, QRect(clipx, clipy, clipw, cliph));
-				m_canvas->DrawPageItems(painter, layer, QRect(clipx, clipy, clipw, cliph));
+				//first pass draws all except notes frames
+				m_canvas->DrawPageItems(painter, layer, QRect(clipx, clipy, clipw, cliph), false);
+				//second draws only notes frames
+				m_canvas->DrawPageItems(painter, layer, QRect(clipx, clipy, clipw, cliph), true);
 			}
 			painter->endLayer();
 			painter->end();
diff --git a/Scribus/scribus/sctextstruct.cpp b/Scribus/scribus/sctextstruct.cpp
index 6b20396..7ddf39d 100644
--- a/Scribus/scribus/sctextstruct.cpp
+++ b/Scribus/scribus/sctextstruct.cpp
@@ -8,6 +8,7 @@ for which a new license (GPL+exception) is in place.
 #include <QObject>
 #include <QList>
 #include <QPointer>
+#include <QChar>
 #include "sctextstruct.h"
 #include "scfonts.h"
 #include "pageitem.h"
@@ -32,6 +33,7 @@ ScText::~ScText()
 	if (parstyle)
 		delete parstyle;
 	parstyle = NULL;
+	mark = NULL;
 }
 
 bool ScText::hasObject(ScribusDoc *doc) const
@@ -41,6 +43,18 @@ bool ScText::hasObject(ScribusDoc *doc) const
 	return false;
 }
 
+bool ScText::hasMark(Mark* MRK) const
+{
+	if (this->ch == SpecialChars::OBJECT)
+	{
+		if (MRK == NULL)
+			return mark != NULL;
+		else
+			return mark == MRK;
+	}
+	return false;
+}
+
 QList<PageItem*> ScText::getGroupedItems(ScribusDoc *doc)
 {
 	QList<PageItem*> result;
@@ -60,3 +74,18 @@ PageItem* ScText::getItem(ScribusDoc *doc)
 		return doc->FrameItems[embedded];
 	return NULL;
 }
+
+// used for check of last visible glyph in text frame
+bool ScText::isVisible()
+{
+	if (ch.isPrint() && !ch.isSpace())
+		return true;
+	if (hasMark() && !mark->isType(MARKAnchorType))
+		return true;
+	if ((ch == SpecialChars::OBJECT) && (embedded != NULL))
+		return true;
+	if ((ch == SpecialChars::PAGENUMBER) || (ch == SpecialChars::PAGECOUNT))
+		return true;
+
+	return false;
+}
diff --git a/Scribus/scribus/sctextstruct.h b/Scribus/scribus/sctextstruct.h
index bfede86..9b4d960 100644
--- a/Scribus/scribus/sctextstruct.h
+++ b/Scribus/scribus/sctextstruct.h
@@ -28,6 +28,7 @@ for which a new license (GPL+exception) is in place.
 #include "styles/paragraphstyle.h"
 
 class PageItem;
+class Mark;
 class ScribusDoc;
 
 /* Struktur fuer Pageitem Text */
@@ -110,6 +111,7 @@ public:
 	float PRot;
 	float PDx;
 	int embedded;
+	Mark* mark;
 	QChar ch;
 	ScText() : 
 		CharStyle(),
@@ -119,7 +121,7 @@ public:
 		CharStyle(other),
 		parstyle(NULL), glyph(other.glyph), 
 		PtransX(other.PtransX), PtransY(other.PtransY), PRot(other.PRot), PDx(other.PDx), 
-		embedded(other.embedded), ch(other.ch)
+		embedded(other.embedded), mark(other.mark), ch(other.ch)
 	{
 		glyph.more = NULL;
 		GlyphLayout *layout = &glyph;
@@ -136,6 +138,9 @@ public:
 	~ScText();
 
 	bool hasObject(ScribusDoc *doc) const;
+	//returns true if given MRK is found, if MRK is NULL then any mark returns true
+	bool hasMark(Mark * MRK = NULL) const;
+	bool isVisible(); //returns true if glyph gives printable and visible sign on page
 	QList<PageItem*> getGroupedItems(ScribusDoc *doc);
 	PageItem* getItem(ScribusDoc *doc);
 };
diff --git a/Scribus/scribus/serializer.cpp b/Scribus/scribus/serializer.cpp
index 32b0a04..0f9db5c 100644
--- a/Scribus/scribus/serializer.cpp
+++ b/Scribus/scribus/serializer.cpp
@@ -138,7 +138,7 @@ class MergeColors_body : public Action_body
 class MergeColors : public MakeAction<MergeColors_body>
 {};
 
-Serializer::Serializer(ScribusDoc& doc) : Digester(), m_Doc(doc)
+Serializer::Serializer(ScribusDoc* doc) : Digester(), m_Doc(doc)
 {
 	// register desaxe rules for styles, colors and elems
 	addRule("/SCRIBUSFRAGMENT", Factory<Collection>());
diff --git a/Scribus/scribus/serializer.h b/Scribus/scribus/serializer.h
index 2e7a498..e4aad46 100644
--- a/Scribus/scribus/serializer.h
+++ b/Scribus/scribus/serializer.h
@@ -53,7 +53,7 @@ public:
 		elements. Since it has Digester as a superclass, a Serializer object can
 	    also be used where a SaxHandler is required as argument, eg. the saxx() method.
 	 */
-	Serializer(ScribusDoc& doc);
+	Serializer(ScribusDoc* doc); //saxing notes needs doc
 	/**
 	  Writes all objects in selection to handler as a fragment. Needed styles and colors
 	  are included.
@@ -80,7 +80,7 @@ public:
 								  const QString& txt);
 
 private:
-	ScribusDoc& m_Doc;
+	ScribusDoc* m_Doc;
 	ColorList backUpColors;
 //	Selection importCollection();
 //	void updateGradientColors(const ColorList& colors);
diff --git a/Scribus/scribus/text/frect.cpp b/Scribus/scribus/text/frect.cpp
index d579e44..f5b77b4 100644
--- a/Scribus/scribus/text/frect.cpp
+++ b/Scribus/scribus/text/frect.cpp
@@ -1,5 +1,5 @@
 /****************************************************************************
-** $Id$
+** $Id: frect.cpp 13161 2009-02-07 00:36:14Z malex $
 **
 ** Implementation of FRect class
 **
diff --git a/Scribus/scribus/text/frect.h b/Scribus/scribus/text/frect.h
index 5f67327..7584581 100644
--- a/Scribus/scribus/text/frect.h
+++ b/Scribus/scribus/text/frect.h
@@ -1,5 +1,5 @@
 /****************************************************************************
-** $Id$
+** $Id: frect.h 13161 2009-02-07 00:36:14Z malex $
 **
 ** Definition of FRect class
 **
diff --git a/Scribus/scribus/text/fsize.cpp b/Scribus/scribus/text/fsize.cpp
index a0cd116..2acfd43 100644
--- a/Scribus/scribus/text/fsize.cpp
+++ b/Scribus/scribus/text/fsize.cpp
@@ -1,5 +1,5 @@
 /****************************************************************************
-** $Id$
+** $Id: fsize.cpp 13161 2009-02-07 00:36:14Z malex $
 **
 ** Implementation of FSize class
 **
diff --git a/Scribus/scribus/text/fsize.h b/Scribus/scribus/text/fsize.h
index 0cc9538..6fffd42 100644
--- a/Scribus/scribus/text/fsize.h
+++ b/Scribus/scribus/text/fsize.h
@@ -1,5 +1,5 @@
 /****************************************************************************
-** $Id$
+** $Id: fsize.h 13161 2009-02-07 00:36:14Z malex $
 **
 ** Definition of FSize class
 **
diff --git a/Scribus/scribus/text/storytext.cpp b/Scribus/scribus/text/storytext.cpp
index 9daf9ce..69ff6cf 100644
--- a/Scribus/scribus/text/storytext.cpp
+++ b/Scribus/scribus/text/storytext.cpp
@@ -26,9 +26,11 @@ pageitem.cpp  -  description
 #include <QList>
 #include <cassert>  //added to make Fedora-5 happy
 #include "fpoint.h"
+#include "notesset.h"
 #include "scfonts.h"
 #include "scribusdoc.h"
 #include "sctext_shared.h"
+#include "selection.h"
 #include "storytext.h"
 #include "scribus.h"
 #include "util.h"
@@ -337,6 +339,7 @@ void StoryText::insert(int pos, const StoryText& other, bool onlySelection)
 		else if (other.text(i) == SpecialChars::OBJECT) {
 			insertChars(pos, SpecialChars::OBJECT);
 			item(pos)->embedded = other.item(i)->embedded;
+			item(pos)->mark = other.item(i)->mark;
 			applyCharStyle(pos, 1, other.charStyle(i));
 			cstyleStart = i+1;
 			pos += 1;
@@ -642,6 +645,17 @@ void StoryText::insertObject(int pos, int ob)
 	doc->FrameItems[ob]->OwnPage = -1; // #10379: OwnPage is not meaningful for inline object
 }
 
+void StoryText::insertMark(Mark* Mark, int pos)
+{
+	if (Mark == NULL)
+		return;
+	if (pos < 0)
+		pos = d->cursorPosition;
+
+	insertChars(pos, SpecialChars::OBJECT, true);
+	const_cast<StoryText *>(this)->d->at(pos)->mark = Mark;
+}
+
 void StoryText::replaceObject(int pos, int ob)
 {
 	if (pos < 0)
@@ -749,6 +763,32 @@ PageItem* StoryText::object(int pos) const
 	return that->d->at(pos)->getItem(doc);
 }
 
+bool StoryText::hasMark(int pos) const
+{
+	if (pos < 0)
+		pos += length();
+
+	assert(pos >= 0);
+	assert(pos < length());
+
+	StoryText* that = const_cast<StoryText *>(this);
+	if (that->d->at(pos)->ch == SpecialChars::OBJECT)
+		return that->d->at(pos)->hasMark();
+	return false;
+}
+
+Mark* StoryText::mark(int pos) const
+{
+	if (pos < 0)
+		pos += length();
+
+	assert(pos >= 0);
+	assert(pos < length());
+
+	StoryText* that = const_cast<StoryText *>(this);
+	return that->d->at(pos)->mark;
+}
+
 const CharStyle & StoryText::charStyle() const
 {
 	return charStyle(d->cursorPosition);
@@ -1452,7 +1492,13 @@ int StoryText::endOfSelection() const
 
 int StoryText::lengthOfSelection() const
 {
-	return selFirst <= selLast? selLast - selFirst + 1 : 0;
+	//FIX ME - sometimes I saw values equal or greater than length of text
+	int last = selLast;
+	if (selFirst >= length())
+		return 0;
+	if (selLast >= length())
+		last = length() -1;
+	return selFirst <= last? last - selFirst + 1 : 0;
 }
 
 
@@ -1611,17 +1657,29 @@ void StoryText::invalidateLayout()
 
 void StoryText::invalidateAll()
 {
+		//FIX ME: realy invalidation is needed before finishing loading document or even if doc is not set?
+	//do not invalidate if doc is not set, doc is loading or signals are blocked
+	//that speeds up layout`s things
+	if (doc == NULL || doc->isLoading() || signalsBlocked())
+		return;
 	d->pstyleContext.invalidate();
 	invalidate(0, nrOfItems());
 }
 
 void StoryText::invalidate(int firstItem, int endItem)
 {
+	//FIX ME: realy invalidation is needed before finishing loading document or even if doc is not set?
+	//do not invalidate if doc is not set, doc is loading or signals are blocked
+	//that speeds up layout`s things
+	if ((doc == NULL) || doc->isLoading() || signalsBlocked())
+		return;
 	for (int i=firstItem; i < endItem; ++i) {
 		ParagraphStyle* par = item(i)->parstyle;
 		if (par)
 			par->charStyleContext()->invalidate();
 	}
+	if (!signalsBlocked())
+		emit changed();
 	emit changed();
 }
 
@@ -1856,6 +1914,35 @@ void StoryText::saxx(SaxHandler& handler, const Xml_string& elemtag) const
 		{
 			object(i)->saxx(handler);
 		}
+		else if (hasMark(i))
+		{
+			Mark* mrk = mark(i);
+			if ((doc->m_Selection->itemAt(0)->isNoteFrame() && mrk->isType(MARKNoteMasterType))
+				|| (!doc->m_Selection->itemAt(0)->isNoteFrame() && mrk->isType(MARKNoteFrameType)))
+				continue; //do not insert notes marks into text frames nad vice versa
+			Xml_attr mark_attr;
+			mark_attr.insert("label", mrk->label);
+			mark_attr.insert("typ", QString::number((int )mrk->getType()));
+			if (mrk->isType(MARK2ItemType) && (mrk->getItemPtr() != NULL))
+				mark_attr.insert("item", mrk->getItemPtr()->itemName());
+			else if (mrk->isType(MARK2MarkType))
+			{
+				QString l;
+				MarkType t;
+				mrk->getMark(l, t);
+				if (doc->getMarkDefinied(l,t) != NULL)
+				{
+					mark_attr.insert("mark_l", l);
+					mark_attr.insert("mark_t", QString::number((int) t));
+				}
+			}
+			else if (mrk->isType(MARKNoteMasterType))
+			{
+				mark_attr.insert("nset", mrk->getNotePtr()->notesSet()->name());
+				mark_attr.insert("note",mrk->getNotePtr()->saxedText());
+			}
+			handler.beginEnd("mark", mark_attr);
+		}
 		else if (curr == SpecialChars::TAB)
 		{
 			handler.beginEnd("tab", empty);
@@ -2016,6 +2103,85 @@ public:
 struct AppendInlineFrame : public MakeAction<AppendInlineFrame_body>
 {};
 
+//marks support
+class AppendMark_body : public Action_body
+{
+public:
+	void begin(const Xml_string& tag, Xml_attr attr)
+	{
+		StoryText* story = this->dig->top<StoryText>();
+		QString l = "";
+		MarkType t = MARKNoType;
+		
+		Mark* mrk = NULL;
+		
+		if (tag == "mark")
+		{
+			Xml_attr::iterator lIt = attr.find("label");
+			Xml_attr::iterator tIt = attr.find("typ");
+			Xml_attr::iterator iIt = attr.find("item");
+			Xml_attr::iterator m_lIt = attr.find("mark_l");
+			Xml_attr::iterator m_tIt = attr.find("mark_t");
+			if (lIt != attr.end())
+				l = Xml_data(lIt);
+			if (tIt != attr.end())
+				t = (MarkType) parseInt(Xml_data(tIt));
+			ScribusDoc* doc  = this->dig->lookup<ScribusDoc>("<scribusdoc>");
+			if (t == MARKVariableTextType)
+				mrk = doc->getMarkDefinied(l,t);
+			else
+			{
+				mrk = new Mark();
+				getUniqueName(l,doc->marksLabelsList(t), "_");
+				mrk->label = l;
+				mrk->OwnPage = doc->currentPage()->pageNr();
+				mrk->setType(t);
+				if (mrk->isType(MARK2ItemType) && (iIt != attr.end()))
+				{
+					PageItem* item = doc->getItemFromName(Xml_data(iIt));
+					mrk->setItemPtr(item);
+					if (item == NULL)
+						mrk->setString("0");
+					else
+						mrk->setString(QString::number(item->OwnPage));
+					mrk->setItemName(Xml_data(iIt));
+				}
+				if (mrk->isType(MARK2MarkType) && (m_lIt != attr.end()) && (m_tIt != attr.end()))
+				{
+					Mark* targetMark = doc->getMarkDefinied(Xml_data(m_lIt), (MarkType) parseInt(Xml_data(m_tIt)));
+					mrk->setMark(targetMark);
+					if (targetMark == NULL)
+						mrk->setString("0");
+					else
+						mrk->setString(QString::number(targetMark->OwnPage));
+					mrk->setItemName(Xml_data(m_lIt));
+				}
+				if (mrk->isType(MARKNoteMasterType))
+				{
+					Xml_attr::iterator nIt = attr.find("note");
+					Xml_attr::iterator nsIt = attr.find("nset");
+					NotesSet* NS;
+					if (nsIt == attr.end())
+						NS = doc->m_docNotesSetsList.at(0);
+					else
+						NS = doc->getNS(Xml_data(nsIt));
+					TextNote* note = new TextNote(NS);
+					note->setMasterMark(mrk);
+					if (nIt != attr.end())
+						note->setSaxedText(Xml_data(nIt));
+					mrk->setNotePtr(note);
+					doc->flag_notesChanged = true;
+				}
+				doc->m_docMarksList.append(mrk);
+			}
+			story->insertMark(mrk);
+		}
+	}
+};
+
+struct AppendMark : public MakeAction<AppendMark_body>
+{};
+
 /*
 class ApplyStyle_body : public Action_body
 {
@@ -2235,5 +2401,6 @@ void StoryText::desaxeRules(const Xml_string& prefixPattern, Digester& ruleset,
 	
 	//PageItem::desaxeRules(storyPrefix, ruleset); argh, that would be recursive!
 	ruleset.addRule(Digester::concat(spanPrefix, "item"), AppendInlineFrame() );
+	ruleset.addRule(Digester::concat(spanPrefix, "mark"), AppendMark() );
 	
 }
diff --git a/Scribus/scribus/text/storytext.h b/Scribus/scribus/text/storytext.h
index f267354..4b40f50 100644
--- a/Scribus/scribus/text/storytext.h
+++ b/Scribus/scribus/text/storytext.h
@@ -30,6 +30,7 @@ pageitem.cpp  -  description
 #include <QList>
 #include <cassert>
 
+#include "marks.h"
 //#include "text/paragraphlayout.h"
 #include "text/frect.h"
 #include "text/specialchars.h"
@@ -132,7 +133,9 @@ class SCRIBUS_API StoryText : public QObject, public SaxIO
 	void insertObject(int obj);
 	// Insert object at specific position
 	void insertObject(int pos, int obj);
- 	void replaceChar(int pos, QChar ch);
+	// Insert mark at cursor or specific position
+	void insertMark(Mark* Mark, int pos = -1);
+	void replaceChar(int pos, QChar ch);
  	// Replaced a word, and return the difference in length between old and new
 	int replaceWord(int pos, QString newWord);
 	void replaceObject(int pos, int obj);
@@ -153,6 +156,8 @@ class SCRIBUS_API StoryText : public QObject, public SaxIO
 
 	bool hasObject(int pos) const;
  	PageItem* object(int pos) const;
+	bool hasMark(int pos) const;
+	Mark *mark(int pos) const;
 	
 	int nextCharPos(int c);
 	int prevCharPos(int c);
diff --git a/Scribus/scribus/ui/MarkInsertDlg.h b/Scribus/scribus/ui/MarkInsertDlg.h
new file mode 100644
index 0000000..7f2e009
--- /dev/null
+++ b/Scribus/scribus/ui/MarkInsertDlg.h
@@ -0,0 +1,40 @@
+#ifndef MARKINSERTDLG_H
+#define MARKINSERTDLG_H
+
+#include <QDialog>
+#include <scribusapi.h>
+
+class NotesSet;
+class Mark;
+class PageItem;
+
+class SCRIBUS_API MarkInsertDlg : public QDialog
+{
+	Q_OBJECT
+
+public:
+	MarkInsertDlg(const QList<Mark*>&, QWidget *parent = 0) : QDialog(parent) {}
+	MarkInsertDlg(const Mark*, QWidget *parent = 0) : QDialog(parent) {}
+	MarkInsertDlg(const QList<NotesSet*>&, QWidget *parent = 0) : QDialog(parent) {}
+	MarkInsertDlg(QWidget *parent = 0) : QDialog(parent) {}
+	~MarkInsertDlg() {}
+
+	virtual void values(QString &label) {}
+	virtual void values(QString &label, PageItem* &item) {}
+	virtual Mark* values(QString& label, QString& text) { return NULL; }
+	virtual void values(QString& label, Mark* &mrk) {}
+	virtual NotesSet* values() { return NULL; }
+
+	virtual void setValues(const QString label) {}
+	virtual void setValues(const QString label, const QString text) {}
+	virtual void setValues(const QString label, const PageItem* ptr) {}
+	virtual void setValues(const QString label, const Mark* ptr) {}
+	virtual void setValues(const NotesSet* defaultSet) {}
+	
+signals:
+
+public slots:
+
+};
+
+#endif // MARKINSERTDLG_H
diff --git a/Scribus/scribus/ui/charselect.cpp b/Scribus/scribus/ui/charselect.cpp
index d00d96e..923da5e 100644
--- a/Scribus/scribus/ui/charselect.cpp
+++ b/Scribus/scribus/ui/charselect.cpp
@@ -102,7 +102,12 @@ void CharSelect::slot_insertSpecialChar()
 	else
 		cItem = m_Item->asTextFrame();
 	if (cItem->HasSel)
+	{
+		//removing marks and notes from selected text
+		if (cItem->isTextFrame() && !cItem->asTextFrame()->removeMarksFromText(!m_doc->hasGUI()))
+			return;
 		cItem->deleteSelectedTextFromFrame();
+	}
 	cItem->invalidateLayout();
 	//CB: Avox please make text->insertchar(char) so none of this happens in gui code, and item can tell doc its changed so the view and mainwindow slotdocch are not necessary
 	QChar ch;
@@ -137,7 +142,12 @@ void CharSelect::slot_insertUserSpecialChar(QChar ch, QString font)
 	else
 		cItem = m_Item->asTextFrame();
 	if (cItem->HasSel)
+	{
+		//removing marks and notes from selected text
+		if (cItem->isTextFrame() && !cItem->asTextFrame()->removeMarksFromText(!m_doc->hasGUI()))
+			return;
 		cItem->deleteSelectedTextFromFrame();
+	}
 	cItem->invalidateLayout();
 // 	//CB: Avox please make text->insertchar(char) so none of this happens in gui code, and item can tell doc its changed so the view and mainwindow slotdocch are not necessary
 	if (ch == QChar(10))
diff --git a/Scribus/scribus/ui/checkDocument.cpp b/Scribus/scribus/ui/checkDocument.cpp
index cdf5f29..2d50881 100644
--- a/Scribus/scribus/ui/checkDocument.cpp
+++ b/Scribus/scribus/ui/checkDocument.cpp
@@ -313,7 +313,9 @@ void CheckDocument::buildErrorList(ScribusDoc *doc)
 
 	if ((doc->docItemErrors.count() == 0)
 		 && (doc->masterItemErrors.count() == 0)
-		 && (doc->docLayerErrors.count() == 0))
+		 && (doc->docLayerErrors.count() == 0)
+	    //this flag is used by documentchecker as indicator for marks change after updating
+		 && !doc->flag_notesChanged)
 	{
 		QTreeWidgetItem * documentItem = new QTreeWidgetItem( reportDisplay );
 		documentItem->setText(COLUMN_ITEM, tr( "Document" ) );
@@ -329,6 +331,16 @@ void CheckDocument::buildErrorList(ScribusDoc *doc)
 		bool layoutGraveError = false;
 		itemError = false;
 // 		QTreeWidgetItem * pagep = 0;
+
+		// MARKS ***********************************************
+		if (doc->flag_notesChanged)
+		{
+			QTreeWidgetItem * marksItem = new QTreeWidgetItem(reportDisplay);
+			marksItem->setText(0, tr("After Marks update document was changed"));
+			marksItem->setIcon(COLUMN_ITEM, onlyWarning );
+			doc->flag_notesChanged = false;
+		}
+
 		// LAYERS **********************************************8
 		QTreeWidgetItem * layerItem = new QTreeWidgetItem(reportDisplay);
 		layerItem->setText(COLUMN_ITEM, tr("Layers"));
diff --git a/Scribus/scribus/ui/contextmenu.cpp b/Scribus/scribus/ui/contextmenu.cpp
index 5906998..a894e7c 100644
--- a/Scribus/scribus/ui/contextmenu.cpp
+++ b/Scribus/scribus/ui/contextmenu.cpp
@@ -24,6 +24,7 @@
 
 #include "contextmenu.h"
 #include "prefsmanager.h"
+#include "pageitem_textframe.h"
 #include "scmimedata.h"
 #include "scraction.h"
 #include "scrapbookpalette.h"
@@ -94,6 +95,7 @@ void ContextMenu::createMenuItems_Selection()
 	QMenu *menuLayer = new QMenu(this);
 	QMenu *menuLevel = new QMenu(this);
 	QMenu *menuPDF = new QMenu(this);
+	QMenu *menuMark = new QMenu(this);
 	QMenu *menuResolution = new QMenu(this);
 //	QMenu *menuWeld = new QMenu(this);
 	
@@ -165,6 +167,38 @@ void ContextMenu::createMenuItems_Selection()
 			addSeparator();
 			addAction(m_AP->scrActions["editEditRenderSource"]);
 		}
+		if (m_doc->appMode == modeEdit)
+		{
+			//add actions for marks in edit mode
+			addSeparator();
+			QAction *act2 = addMenu(menuMark);
+			act2->setText( ScribusView::tr("Insert Mark"));
+			menuMark->addAction(m_AP->scrActions["insertMarkVariableText"]);
+			if (m_actionList.contains("insertMarkAnchor"))
+			{
+				if (!currItem->isNoteFrame())
+					menuMark->addAction(m_AP->scrActions["insertMarkAnchor"]);
+				menuMark->addAction(m_AP->scrActions["insertMarkItem"]);
+				menuMark->addAction(m_AP->scrActions["insertMark2Mark"]);
+				if (!currItem->isNoteFrame())
+				{
+					menuMark->addAction(m_AP->scrActions["insertMarkNote"]);
+				//	menuMark->addAction(m_AP->scrActions["insertMarkIndex"]);
+				}
+			}
+			if (currItem->itemText.cursorPosition() < currItem->itemText.length())
+			{
+				ScText *hl = currItem->itemText.item(currItem->itemText.cursorPosition());
+				if (hl->hasMark())
+					addAction(m_AP->scrActions["editMark"]);
+			}
+		}
+		if (currItem->asTextFrame()->hasAnyMark())
+		{
+			if (m_doc->appMode != modeEdit)
+				addSeparator();
+			addAction(m_AP->scrActions["itemUpdateMarks"]);
+		}
 		if (m_actionList.contains("fileImportText"))
 		{
 			addSeparator();
diff --git a/Scribus/scribus/ui/copypagetomasterpagedialog.cpp b/Scribus/scribus/ui/copypagetomasterpagedialog.cpp
index 470eb60..e53d197 100644
--- a/Scribus/scribus/ui/copypagetomasterpagedialog.cpp
+++ b/Scribus/scribus/ui/copypagetomasterpagedialog.cpp
@@ -5,34 +5,22 @@ a copyright and/or license notice that predates the release of Scribus 1.3.2
 for which a new license (GPL+exception) is in place.
 */
 
-#include <QAbstractButton>
 #include <QCheckBox>
 #include <QLineEdit>
-#include "commonstrings.h"
+
 #include "copypagetomasterpagedialog.h"
 
 CopyPageToMasterPageDialog::CopyPageToMasterPageDialog(int existingMasterNamesCount, const QStringList& pageLocations, int currentLocation, QWidget *parent)
  : QDialog(parent)
 {
 	setupUi(this);
-
-	QList<QAbstractButton *> buttonList = buttonBox->buttons();
-	foreach (QAbstractButton* b, buttonList)
-	{
-		if (buttonBox->buttonRole(b)==QDialogButtonBox::AcceptRole)
-			b->setText(CommonStrings::tr_OK);
-		else
-		if (buttonBox->buttonRole(b)==QDialogButtonBox::RejectRole)
-			b->setText(CommonStrings::tr_Cancel);
-	}
-
+	
 	nameLineEdit->setText( tr("New Master Page %1").arg(existingMasterNamesCount));
 	if (currentLocation==-1)
 		pagePositionComboBox->hide();
 	else
 	{
-		foreach (QString untranslatedPageName, pageLocations)
-			pagePositionComboBox->addItem(CommonStrings::translatePageSetLocString(untranslatedPageName));
+		pagePositionComboBox->addItems(pageLocations);
 		pagePositionComboBox->setCurrentIndex(currentLocation);
 	}
 }
diff --git a/Scribus/scribus/ui/loremipsum.cpp b/Scribus/scribus/ui/loremipsum.cpp
index bd84fcc..466992a 100644
--- a/Scribus/scribus/ui/loremipsum.cpp
+++ b/Scribus/scribus/ui/loremipsum.cpp
@@ -280,6 +280,12 @@ void LoremManager::insertLoremIpsum(QString name, int paraCount, bool random)
 		PageItem* currItem = m_Doc->m_Selection->itemAt(i);
 		if (currItem == NULL)
 			continue;
+		//do not insert lorem ipsum text into notes frames
+		if (currItem->isNoteFrame())
+			continue;
+		//removing marks and notes from current text
+		if (currItem->isTextFrame() && !currItem->asTextFrame()->removeMarksFromText(!m_Doc->hasGUI()))
+			continue;
 		PageItem *i2 = currItem;
 		if (m_Doc->appMode == modeEditTable)
 			i2 = currItem->asTable()->activeCell().textFrame();
@@ -324,7 +330,7 @@ void LoremManager::insertLoremIpsum(QString name, int paraCount, bool random)
 		delete lp;
 		if (m_Doc->docHyphenator->AutoCheck)
 			m_Doc->docHyphenator->slotHyphenate(i2);
-		i2->invalidateLayout();
+		i2->asTextFrame()->invalidateLayout(true);
 	}
 	m_Doc->regionsChanged()->update(QRectF());
 	m_Doc->changed();
diff --git a/Scribus/scribus/ui/mark2item.cpp b/Scribus/scribus/ui/mark2item.cpp
new file mode 100644
index 0000000..edf42ef
--- /dev/null
+++ b/Scribus/scribus/ui/mark2item.cpp
@@ -0,0 +1,51 @@
+#include "mark2item.h"
+#include "notesset.h"
+#include "pageitem_noteframe.h"
+#include "scribus.h"
+
+Mark2ItemDlg::Mark2ItemDlg(QWidget *parent) : MarkInsertDlg(parent)
+{
+	setupUi(this);
+	ScribusMainWindow* scmw = (ScribusMainWindow*) parent;
+	QStringList itemsList;
+
+	for (int i = 0; i < scmw->doc->Items->count(); i++)
+	{
+		PageItem* item = scmw->doc->Items->at(i);
+		if (item->isNoteFrame() && item->asNoteFrame()->isAutoRemove())
+			continue; //omit notes frames automaticaly created and removed
+		itemsList.append(item->itemName());
+	}
+	ItemList->addItems(itemsList);
+	setWindowTitle(tr("Mark to Item"));
+}
+
+void Mark2ItemDlg::values(QString &label, PageItem* &ptr)
+{
+	QString itemName = ItemList->currentText();
+	if (itemName != "")
+	{
+		ScribusMainWindow* scmw = (ScribusMainWindow*) parent();
+		ptr = scmw->doc->getItemFromName(itemName);
+		label = labelEdit->text();
+	}
+}
+
+void Mark2ItemDlg::setValues(const QString label, const PageItem* ptr)
+{
+	int index = (ptr == NULL)? -1:ItemList->findText(ptr->itemName());
+	ItemList->setCurrentIndex(index);
+	labelEdit->setText(label);
+}
+
+void Mark2ItemDlg::changeEvent(QEvent *e)
+{
+    QDialog::changeEvent(e);
+    switch (e->type()) {
+    case QEvent::LanguageChange:
+        retranslateUi(this);
+        break;
+    default:
+        break;
+    }
+}
diff --git a/Scribus/scribus/ui/mark2item.h b/Scribus/scribus/ui/mark2item.h
new file mode 100644
index 0000000..6565fef
--- /dev/null
+++ b/Scribus/scribus/ui/mark2item.h
@@ -0,0 +1,20 @@
+#ifndef MARK2ITEM_H
+#define MARK2ITEM_H
+
+#include "MarkInsertDlg.h"
+#include "ui_mark2item.h"
+
+class SCRIBUS_API Mark2ItemDlg : public MarkInsertDlg, private Ui::Mark2ItemDlg
+{
+    Q_OBJECT
+
+public:
+	explicit Mark2ItemDlg(QWidget *parent = 0);
+	virtual void values(QString &label, PageItem* &ptr);
+	virtual void setValues(const QString label, const PageItem* ptr);
+
+protected:
+	void changeEvent(QEvent *e);
+};
+
+#endif // MARK2ITEM_H
diff --git a/Scribus/scribus/ui/mark2item.ui b/Scribus/scribus/ui/mark2item.ui
new file mode 100644
index 0000000..0a7aea3
--- /dev/null
+++ b/Scribus/scribus/ui/mark2item.ui
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Mark2ItemDlg</class>
+ <widget class="QDialog" name="Mark2ItemDlg">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>349</width>
+    <height>102</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>16777215</width>
+    <height>115</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <layout class="QFormLayout" name="formLayout">
+     <property name="fieldGrowthPolicy">
+      <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
+     </property>
+     <item row="0" column="0">
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Label:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="1">
+      <widget class="QLineEdit" name="labelEdit"/>
+     </item>
+     <item row="1" column="0">
+      <widget class="QLabel" name="label_2">
+       <property name="text">
+        <string>Item:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1">
+      <widget class="QComboBox" name="ItemList">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="editable">
+        <bool>false</bool>
+       </property>
+       <property name="currentIndex">
+        <number>-1</number>
+       </property>
+       <property name="duplicatesEnabled">
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="1" column="0">
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>164</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QDialogButtonBox" name="buttonBox">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="standardButtons">
+        <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>Mark2ItemDlg</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>262</x>
+     <y>90</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>174</x>
+     <y>54</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>Mark2ItemDlg</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>262</x>
+     <y>90</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>174</x>
+     <y>54</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/Scribus/scribus/ui/mark2mark.cpp b/Scribus/scribus/ui/mark2mark.cpp
new file mode 100644
index 0000000..6033c11
--- /dev/null
+++ b/Scribus/scribus/ui/mark2mark.cpp
@@ -0,0 +1,101 @@
+#include "marks.h"
+#include "mark2mark.h"
+#include <QStandardItemModel>
+
+Mark2MarkDlg::Mark2MarkDlg(const QList<Mark*>& marks, Mark* omitMark, QWidget *parent) : MarkInsertDlg(marks, parent)
+{
+	setupUi(this);
+	LabelList->addItem("", QVariant::fromValue((void*) NULL));
+	
+	//for each marks type
+	QString typeStr;
+	MarkType typeMrk;
+
+	int index = 0;
+	typeMrk = MARKAnchorType;	typeStr = tr("Anchors");
+	//adding name of marks type, and make it unselectable
+	LabelList->addItem("+++ " + typeStr);
+	qobject_cast<QStandardItemModel *>(LabelList->model())->item( ++index )->setEnabled( false );
+	for (int i = 0; i < marks.size(); ++i)
+	{
+		if (marks[i]->isType(typeMrk))
+		{
+			LabelList->addItem(marks[i]->label, QVariant::fromValue((void*) marks[i]));
+			index++;
+		}
+	}
+	typeMrk = MARK2MarkType;	typeStr = tr("Mark to Mark");
+	LabelList->addItem("+++ " + typeStr);
+	qobject_cast<QStandardItemModel *>(LabelList->model())->item( ++index )->setEnabled( false );
+	for (int i = 0; i < marks.size(); ++i)
+	{
+		if (marks[i]->isType(typeMrk) && marks[i] != omitMark)
+		{
+			LabelList->addItem(marks[i]->label, QVariant::fromValue((void*) marks[i]));
+			index++;
+		}
+	}
+	typeMrk = MARK2ItemType;	typeStr = tr("Mark to Item");
+	LabelList->addItem("+++ " + typeStr);
+	qobject_cast<QStandardItemModel *>(LabelList->model())->item( ++index )->setEnabled( false );
+	for (int i = 0; i < marks.size(); ++i)
+	{
+		if (marks[i]->isType(typeMrk))
+		{
+			LabelList->addItem(marks[i]->label, QVariant::fromValue((void*) marks[i]));
+			index++;
+		}
+	}
+	typeMrk = MARKNoteMasterType;	typeStr = tr("Note mark");
+	LabelList->addItem("+++ " + typeStr);
+	qobject_cast<QStandardItemModel *>(LabelList->model())->item( ++index )->setEnabled( false );
+	for (int i = 0; i < marks.size(); ++i)
+	{
+		if (marks[i]->isType(typeMrk))
+		{
+			LabelList->addItem(marks[i]->label, QVariant::fromValue((void*) marks[i]));
+			index++;
+		}
+	}
+//	typeMrk = MARKIndexType;	typeStr = tr("Index entry");
+//	LabelList->addItem("+++ " + typeStr);
+//	qobject_cast<QStandardItemModel *>(LabelList->model())->item( ++index )->setEnabled( false );
+//	for (int i = 0; i < marks.size(); ++i)
+//	{
+//		if (marks[i]->isType(typeMrk))
+//		{
+//			LabelList->addItem(marks[i]->label, QVariant::fromValue((void*) marks[i]));
+//			index++;
+//		}
+//	}
+	setWindowTitle(tr("Mark to Mark"));
+}
+
+void Mark2MarkDlg::values(QString& label, Mark* &mrk)
+{
+	label = this->labelEdit->text();
+	int labelID = LabelList->currentIndex();
+	if (labelID == 0)
+		mrk= NULL;
+	else
+		mrk = (Mark*) LabelList->itemData(labelID).value<void*>();
+}
+
+void Mark2MarkDlg::setValues(const QString label, const Mark* mrk)
+{
+	int index = (mrk == NULL)? -1:LabelList->findText(mrk->label);
+	LabelList->setCurrentIndex(index);
+	labelEdit->setText(label);
+}
+
+void Mark2MarkDlg::changeEvent(QEvent *e)
+{
+    QDialog::changeEvent(e);
+    switch (e->type()) {
+    case QEvent::LanguageChange:
+        retranslateUi(this);
+        break;
+    default:
+        break;
+    }
+}
diff --git a/Scribus/scribus/ui/mark2mark.h b/Scribus/scribus/ui/mark2mark.h
new file mode 100644
index 0000000..7104329
--- /dev/null
+++ b/Scribus/scribus/ui/mark2mark.h
@@ -0,0 +1,20 @@
+#ifndef MARK2MARK_H
+#define MARK2MARK_H
+
+#include "MarkInsertDlg.h"
+#include "ui_mark2mark.h"
+
+class SCRIBUS_API Mark2MarkDlg : public MarkInsertDlg, private Ui::Mark2MarkDlg
+{
+    Q_OBJECT
+
+public:
+	explicit Mark2MarkDlg(const QList<Mark*>& marks, Mark* omitMark = NULL, QWidget *parent = NULL);
+	virtual void values(QString& label, Mark* &mrk);
+	virtual void setValues(const QString label, const Mark* mrk);
+
+protected:
+    void changeEvent(QEvent *e);
+};
+
+#endif // MARK2MARK_H
diff --git a/Scribus/scribus/ui/mark2mark.ui b/Scribus/scribus/ui/mark2mark.ui
new file mode 100644
index 0000000..9b7d069
--- /dev/null
+++ b/Scribus/scribus/ui/mark2mark.ui
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Mark2MarkDlg</class>
+ <widget class="QDialog" name="Mark2MarkDlg">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>362</width>
+    <height>103</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>0</width>
+    <height>103</height>
+   </size>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>16777215</width>
+    <height>103</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QSplitter" name="splitter">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <widget class="QLabel" name="label_2">
+      <property name="text">
+       <string>Label:</string>
+      </property>
+     </widget>
+     <widget class="QLineEdit" name="labelEdit"/>
+    </widget>
+   </item>
+   <item>
+    <widget class="QSplitter" name="splitter_2">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <widget class="QLabel" name="label">
+      <property name="text">
+       <string>Select marker:</string>
+      </property>
+     </widget>
+     <widget class="QComboBox" name="LabelList">
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+        <horstretch>0</horstretch>
+        <verstretch>0</verstretch>
+       </sizepolicy>
+      </property>
+      <property name="editable">
+       <bool>false</bool>
+      </property>
+      <property name="currentIndex">
+       <number>-1</number>
+      </property>
+      <property name="duplicatesEnabled">
+       <bool>false</bool>
+      </property>
+     </widget>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>166</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QDialogButtonBox" name="buttonBox">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="standardButtons">
+        <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>Mark2MarkDlg</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>262</x>
+     <y>90</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>174</x>
+     <y>54</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>Mark2MarkDlg</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>262</x>
+     <y>90</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>174</x>
+     <y>54</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/Scribus/scribus/ui/markanchor.cpp b/Scribus/scribus/ui/markanchor.cpp
new file mode 100644
index 0000000..93867e7
--- /dev/null
+++ b/Scribus/scribus/ui/markanchor.cpp
@@ -0,0 +1,30 @@
+#include "markanchor.h"
+
+MarkAnchorDlg::MarkAnchorDlg(QWidget *parent) :
+	MarkInsertDlg(parent)
+{
+	setupUi(this);
+	setWindowTitle(tr("Anchor Mark"));
+}
+
+void MarkAnchorDlg:: values(QString& label)
+{
+	label = labelEdit->text();
+}
+
+void MarkAnchorDlg::setValues(const QString label)
+{
+	labelEdit->setText(label);
+}
+
+void MarkAnchorDlg::changeEvent(QEvent *e)
+{
+	QDialog::changeEvent(e);
+	switch (e->type()) {
+		case QEvent::LanguageChange:
+			retranslateUi(this);
+			break;
+		default:
+			break;
+	}
+}
diff --git a/Scribus/scribus/ui/markanchor.h b/Scribus/scribus/ui/markanchor.h
new file mode 100644
index 0000000..cd13b5a
--- /dev/null
+++ b/Scribus/scribus/ui/markanchor.h
@@ -0,0 +1,20 @@
+#ifndef MARKANCHOR_H
+#define MARKANCHOR_H
+
+#include "MarkInsertDlg.h"
+#include "ui_markanchor.h"
+
+class SCRIBUS_API MarkAnchorDlg : public MarkInsertDlg, private Ui::MarkAnchorDlg
+{
+    Q_OBJECT
+
+public:
+	explicit MarkAnchorDlg(QWidget *parent = 0);
+	~MarkAnchorDlg() {}
+	virtual void values(QString& label);
+	virtual void setValues(const QString label);
+protected:
+	void changeEvent(QEvent *e);
+};
+
+#endif // MARKANCHOR_H
diff --git a/Scribus/scribus/ui/markanchor.ui b/Scribus/scribus/ui/markanchor.ui
new file mode 100644
index 0000000..f152fcd
--- /dev/null
+++ b/Scribus/scribus/ui/markanchor.ui
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MarkAnchorDlg</class>
+ <widget class="QDialog" name="MarkAnchorDlg">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>81</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>0</width>
+    <height>81</height>
+   </size>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>16777215</width>
+    <height>81</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Label:</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1">
+    <widget class="QLineEdit" name="labelEdit"/>
+   </item>
+   <item row="1" column="1">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>MarkAnchorDlg</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>MarkAnchorDlg</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/Scribus/scribus/ui/marknote.cpp b/Scribus/scribus/ui/marknote.cpp
new file mode 100644
index 0000000..5a3d8e5
--- /dev/null
+++ b/Scribus/scribus/ui/marknote.cpp
@@ -0,0 +1,40 @@
+#include "marknote.h"
+#include "scribus.h"
+
+MarkNoteDlg::MarkNoteDlg(const QList<NotesSet*>& notessetList, QWidget *parent) :
+	MarkInsertDlg(notessetList, parent)
+{
+	setupUi(this);
+
+	for (int i = 0; i < notessetList.count(); i++)
+		ItemList->addItem(notessetList.at(i)->name(), QVariant::fromValue((void*) notessetList.at(i)));
+	setWindowTitle(tr("Insert Foot/Endnote"));
+}
+
+NotesSet* MarkNoteDlg::values()
+{
+	int index = ItemList->currentIndex();
+	return (NotesSet*) ItemList->itemData(index).value<void*>();
+}
+
+void MarkNoteDlg::setValues(NotesSet* defaultSet)
+{
+	ItemList->setCurrentIndex(ItemList->findText(defaultSet->name()));
+}
+
+void MarkNoteDlg::changeEvent(QEvent *e)
+{
+	QDialog::changeEvent(e);
+	switch (e->type()) {
+		case QEvent::LanguageChange:
+			retranslateUi(this);
+			break;
+		default:
+			break;
+	}
+}
+
+void MarkNoteDlg::on_buttonBox_accepted()
+{
+    
+}
diff --git a/Scribus/scribus/ui/marknote.h b/Scribus/scribus/ui/marknote.h
new file mode 100644
index 0000000..838dff5
--- /dev/null
+++ b/Scribus/scribus/ui/marknote.h
@@ -0,0 +1,22 @@
+#ifndef MARKNOTE_H
+#define MARKNOTE_H
+
+#include "MarkInsertDlg.h"
+#include "notesset.h"
+#include "ui_marknote.h"
+
+class SCRIBUS_API MarkNoteDlg : public MarkInsertDlg, private Ui::MarkNoteDlg
+{
+	Q_OBJECT
+	
+public:
+	explicit MarkNoteDlg(const QList<NotesSet*>& notessetList, QWidget *parent = NULL);
+	virtual NotesSet* values();
+	virtual void setValues(NotesSet* defaultSet);
+protected:
+	void changeEvent(QEvent *e);
+private slots:
+	void on_buttonBox_accepted();
+};
+
+#endif // MARKNOTE_H
diff --git a/Scribus/scribus/ui/marknote.ui b/Scribus/scribus/ui/marknote.ui
new file mode 100644
index 0000000..fa78fef
--- /dev/null
+++ b/Scribus/scribus/ui/marknote.ui
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MarkNoteDlg</class>
+ <widget class="QDialog" name="MarkNoteDlg">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>358</width>
+    <height>80</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>16777215</width>
+    <height>80</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <layout class="QFormLayout" name="formLayout">
+     <property name="fieldGrowthPolicy">
+      <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
+     </property>
+     <property name="formAlignment">
+      <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+     </property>
+     <item row="0" column="1">
+      <widget class="QComboBox" name="ItemList">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="editable">
+        <bool>false</bool>
+       </property>
+       <property name="currentIndex">
+        <number>-1</number>
+       </property>
+       <property name="duplicatesEnabled">
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="0">
+      <widget class="QLabel" name="label_2">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string>Numeration Set:</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="1" column="0">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>MarkNoteDlg</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>178</x>
+     <y>55</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>178</x>
+     <y>39</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>MarkNoteDlg</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>178</x>
+     <y>55</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>178</x>
+     <y>39</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/Scribus/scribus/ui/marksmanager.cpp b/Scribus/scribus/ui/marksmanager.cpp
new file mode 100644
index 0000000..10b8770
--- /dev/null
+++ b/Scribus/scribus/ui/marksmanager.cpp
@@ -0,0 +1,223 @@
+#include "marksmanager.h"
+#include "prefsmanager.h"
+#include "prefsfile.h"
+#include "scribus.h"
+#include "scribusdoc.h"
+#include <QStandardItemModel>
+
+MarksManager::MarksManager(QWidget *parent, const char *name)
+	: ScrPaletteBase(parent, name), m_doc(NULL)
+{
+	setupUi(this);
+	listView->setSelectionMode(QAbstractItemView::SingleSelection);
+	listView->setSortingEnabled(true);
+	listView->setHeaderHidden(true);
+	listView->setColumnCount(1);
+	QString pname(name);
+	if (pname.isEmpty())
+		pname = "marksManager";
+	m_prefs = PrefsManager::instance()->prefsFile->getContext(pname);
+	setDoc(0);
+	languageChange();
+	EditButton->setEnabled(false);
+	DeleteButton->setEnabled(false);
+	UpdateButton->setEnabled(false);
+}
+
+MarksManager::~MarksManager()
+{
+	storeVisibility(this->isVisible());
+	storePosition();
+	storeSize();
+}
+
+void MarksManager::addListItem(MarkType typeMrk, QString typeStr, QList<Mark*> &marks, int &index)
+{
+	bool noSuchMarks = true;
+	QTreeWidgetItem *listItem = new QTreeWidgetItem(listView);
+	listItem->setText(0,typeStr);
+	listItem->setFlags(listItem->flags() & (~Qt::ItemIsSelectable));
+	listItem->setBackground(0,QColor("lightGray"));
+	for (int i = 0; i < marks.size(); ++i)
+	{
+		if (marks[i]->isType(typeMrk))
+		{
+			QTreeWidgetItem *listItem2 = new QTreeWidgetItem(listItem);
+			listItem2->setText(0, marks[i]->label);
+			listItem2->setData(0, Qt::UserRole,QVariant::fromValue<void*>(marks[i]));
+			index++;
+			noSuchMarks = false;
+		}
+	}
+	if (noSuchMarks)
+	{
+		listView->removeItemWidget(listItem,0);
+		delete listItem;
+	}
+}
+
+void MarksManager::storeColaption()
+{
+	expandedItems.clear();
+	for (int i=0; i < listView->topLevelItemCount(); ++i)
+	{
+		QTreeWidgetItem *item = listView->topLevelItem(i);
+		if (item->isExpanded())
+		{
+			expandedItems.append(item->text(0));
+		}
+	}
+}
+
+void MarksManager::restoreColaption()
+{
+	listView->collapseAll();
+	if (!expandedItems.isEmpty())
+	{
+		for (int i=0; i < listView->topLevelItemCount(); ++i)
+		{
+			QTreeWidgetItem *item = listView->topLevelItem(i);
+			if (expandedItems.contains(item->text(0)))
+				listView->topLevelItem(i)->setExpanded(true);
+		}
+	}
+}
+
+void MarksManager::updateListView()
+{
+	storeColaption();
+	listView->clear();
+	if (m_doc == NULL)
+		return;
+	if (m_doc->m_docMarksList.isEmpty())
+		UpdateButton->setEnabled(false);
+	else
+	{
+		UpdateButton->setEnabled(true);
+		int index = 0;
+		addListItem(MARKAnchorType, tr("Anchors"), m_doc->m_docMarksList, index);
+		addListItem(MARKVariableTextType, tr("Variable Text"), m_doc->m_docMarksList, index);
+		addListItem(MARK2ItemType, tr("Marks to Items"), m_doc->m_docMarksList, index);
+		addListItem(MARK2MarkType, tr("Marks to Anchors"), m_doc->m_docMarksList, index);
+		addListItem(MARKNoteMasterType, tr("Notes marks"), m_doc->m_docMarksList, index);
+	//	addListItem(MARKIndexType, tr("Index entries");, marks, index);
+		listView->sortByColumn(0);
+	}
+	restoreColaption();
+	m_doc->flag_updateNotesLabels = false;
+	m_doc->flag_updateEndNotes = false;
+}
+
+void MarksManager::setDoc(ScribusDoc *doc)
+{
+	if (m_doc != NULL)
+		disconnect(m_doc->scMW(), SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int)));
+	bool hasDoc = (doc != NULL);
+	m_doc = doc;
+	if (hasDoc)
+	{
+		UpdateButton->setEnabled(true);
+		listView->setEnabled(true);
+		updateListView();
+		connect(m_doc->scMW(), SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int)));
+	}
+	else
+		listView->clear();
+}
+
+void MarksManager::languageChange()
+{
+	setWindowTitle(tr("Marks Manager"));
+	listView->setToolTip(tr("Double click to find mark in text"));
+	UpdateButton->setText(tr("Update All Marks"));
+	UpdateButton->setToolTip(tr("Update all refeence texts for all marks"));
+	EditButton->setText(tr("Edit"));
+	EditButton->setToolTip(tr("Edit selected mark"));
+	if (m_doc != NULL)
+		updateListView();
+}
+
+void MarksManager::handleUpdateRequest(int updateFlags)
+{
+	if (updateFlags & reqMarksUpdate)
+		updateListView();
+}
+
+Mark* MarksManager::getMarkFromListView()
+{
+	QTreeWidgetItem* selectedItem = listView->currentItem();
+	if (selectedItem == NULL)
+		return NULL;
+	Mark* mrk = reinterpret_cast<Mark*>(selectedItem->data(0, Qt::UserRole).value<void*>());
+	return mrk;
+}
+
+void MarksManager::on_UpdateButton_clicked()
+{
+	m_doc->flag_updateNotesLabels = true;
+	m_doc->flag_updateEndNotes = true;
+	if (m_doc->updateMarks(true))
+	{
+		m_doc->changed();
+		m_doc->regionsChanged()->update(QRectF());
+		updateListView();
+	}
+
+	//update lables for "lost" marks (marks not in any text)
+	QList<Mark*> notUsed;
+	for (int a=0; a < m_doc->m_docMarksList.count(); ++a)
+	{
+		Mark* mrk = m_doc->m_docMarksList.at(a);
+		if (mrk->isUnique() && !mrk->label.startsWith("UNVISIBLE*") && !m_doc->isMarkUsed(mrk, true))
+			notUsed.append(mrk);
+	}
+	if (!notUsed.isEmpty())
+	{
+		for (int a=0; a<notUsed.count(); ++a)
+		{
+			Mark* mrk = notUsed.at(a);
+			QString l = "UNVISIBLE*" + mrk->label;
+			getUniqueName(l,m_doc->marksLabelsList(mrk->getType()),"_");
+			mrk->label = l;
+		}
+		updateListView();
+	}
+}
+
+void MarksManager::on_EditButton_clicked()
+{
+	Mark* mrk = getMarkFromListView();
+	if (mrk != NULL)
+	{
+		if (m_doc->scMW()->editMarkDlg(mrk))
+		{
+			m_doc->changed();
+			m_doc->regionsChanged()->update(QRectF());
+			updateListView();
+		}
+	}
+}
+
+void MarksManager::on_DeleteButton_clicked()
+{
+	Mark* mrk = getMarkFromListView();
+	if (mrk != NULL)
+	{
+		m_doc->eraseMark(mrk, true);
+		updateListView();
+	}
+}
+
+void MarksManager::on_listView_doubleClicked(const QModelIndex &index)
+{
+	Mark* mrk = getMarkFromListView();
+	if (mrk != NULL)
+		m_doc->setCursor2MarkPos(mrk);
+}
+
+void MarksManager::on_listView_itemSelectionChanged()
+{
+	bool isMark = (getMarkFromListView() != NULL);
+	EditButton->setEnabled(isMark);
+	DeleteButton->setEnabled(isMark);
+}
diff --git a/Scribus/scribus/ui/marksmanager.h b/Scribus/scribus/ui/marksmanager.h
new file mode 100644
index 0000000..d410b1e
--- /dev/null
+++ b/Scribus/scribus/ui/marksmanager.h
@@ -0,0 +1,42 @@
+#ifndef MARKSMANAGER_H
+#define MARKSMANAGER_H
+
+#include <QList>
+#include <QTreeWidgetItem>
+#include "ui/scrpalettebase.h"
+#include "ui_marksmanager.h"
+#include "marks.h"
+class QEvent;
+class  ScribusDoc;
+
+class SCRIBUS_API MarksManager : public ScrPaletteBase, Ui::MarksManager
+{
+	Q_OBJECT
+
+public:
+	explicit MarksManager(QWidget *parent = 0, const char *name = "MarksManager");
+	~MarksManager();
+	void updateListView();
+private:
+	ScribusDoc         *m_doc;
+	PrefsContext       *m_prefs;
+	Mark* getMarkFromListView();
+	void addListItem(MarkType typeMrk, QString typeStr, QList<Mark *> &marks, int &index);
+	QStringList expandedItems;
+	void storeColaption();
+	void restoreColaption();
+
+public slots:
+	void setDoc(ScribusDoc *doc);
+	void languageChange();
+	void handleUpdateRequest(int updateFlags);
+
+private slots:
+	void on_UpdateButton_clicked();
+	void on_EditButton_clicked();
+	void on_DeleteButton_clicked();
+	void on_listView_doubleClicked(const QModelIndex &index);
+	void on_listView_itemSelectionChanged();
+};
+
+#endif // MARKSMANAGER_H
diff --git a/Scribus/scribus/ui/marksmanager.ui b/Scribus/scribus/ui/marksmanager.ui
new file mode 100644
index 0000000..c166897
--- /dev/null
+++ b/Scribus/scribus/ui/marksmanager.ui
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MarksManager</class>
+ <widget class="QDialog" name="MarksManager">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>253</width>
+    <height>249</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>200</width>
+    <height>100</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <property name="modal">
+   <bool>false</bool>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="1" column="0">
+    <widget class="QPushButton" name="UpdateButton">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="text">
+      <string>Update All Marks</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="0">
+    <widget class="QSplitter" name="splitter">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <widget class="QPushButton" name="EditButton">
+      <property name="text">
+       <string>Edit</string>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="DeleteButton">
+      <property name="text">
+       <string>Delete</string>
+      </property>
+     </widget>
+    </widget>
+   </item>
+   <item row="0" column="0">
+    <widget class="QTreeWidget" name="listView">
+     <property name="editTriggers">
+      <set>QAbstractItemView::DoubleClicked</set>
+     </property>
+     <property name="showDropIndicator" stdset="0">
+      <bool>false</bool>
+     </property>
+     <property name="selectionMode">
+      <enum>QAbstractItemView::NoSelection</enum>
+     </property>
+     <property name="selectionBehavior">
+      <enum>QAbstractItemView::SelectItems</enum>
+     </property>
+     <property name="horizontalScrollMode">
+      <enum>QAbstractItemView::ScrollPerPixel</enum>
+     </property>
+     <column>
+      <property name="text">
+       <string notr="true">1</string>
+      </property>
+     </column>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Scribus/scribus/ui/markvariabletext.cpp b/Scribus/scribus/ui/markvariabletext.cpp
new file mode 100644
index 0000000..05f2cfa
--- /dev/null
+++ b/Scribus/scribus/ui/markvariabletext.cpp
@@ -0,0 +1,95 @@
+#include "markvariabletext.h"
+#include "marks.h"
+#include <QComboBox>
+
+MarkVariableTextDlg::MarkVariableTextDlg(const QList<Mark*>& marks, QWidget *parent) : MarkInsertDlg(marks, parent)
+{
+	//for editing mark entry in text - user can change mark pointer inserted into text or create new mark entry
+	setupUi(this);
+
+	labelEditWidget = (QWidget*) new QComboBox(parent);
+	((QComboBox*) labelEditWidget)->addItem(tr("New Mark"), QVariant::fromValue((void*) NULL));
+	for (int i = 0; i < marks.size(); ++i)
+	{
+		if (marks[i]->isType(MARKVariableTextType))
+			((QComboBox*) labelEditWidget)->addItem(marks[i]->label, QVariant::fromValue((void*) marks[i]));
+	}
+	((QComboBox*) labelEditWidget)->setEditable(true);
+	((QComboBox*) labelEditWidget)->lineEdit()->setToolTip(tr("Edit selected Mark`s label. To create new Mark select \"New Mark\" in drop list and input new label"));
+	connect(((QComboBox*) labelEditWidget), SIGNAL(currentIndexChanged(int)),this,SLOT(onLabelList_currentIndexChanged(int)));
+	labelLayout->addWidget(labelEditWidget);
+	textEdit->setToolTip(tr("Edit variable text"));
+	setWindowTitle(tr("Mark with Variable Text"));
+}
+
+MarkVariableTextDlg::MarkVariableTextDlg(const Mark* mark, QWidget *parent) : MarkInsertDlg(mark, parent), mrk(mark)
+{
+	//for editing by marks Manager - user can change label and variable text
+	setupUi(this);
+
+	labelEditWidget = (QWidget*) new QLineEdit(parent);
+	((QLineEdit*) labelEditWidget)->setToolTip(tr("Edit selected Mark`s label."));
+
+	labelLayout->addWidget(labelEditWidget);
+	textEdit->setToolTip(tr("Edit variable text"));
+	setWindowTitle(tr("Mark with Variable Text"));
+}
+
+MarkVariableTextDlg::~MarkVariableTextDlg()
+{
+	//delete ui;
+	delete labelEditWidget;
+}
+
+Mark* MarkVariableTextDlg::values(QString& label, QString& text)
+{
+	text = textEdit->text();
+	//hack to read if it is QComboBox or QLineEdit
+	if (labelEditWidget->toolTip() != tr("Edit selected Mark`s label."))
+	{
+		int labelID = ((QComboBox*) labelEditWidget)->currentIndex();
+		label = ((QComboBox*) labelEditWidget)->currentText();
+		if (label == tr("New Mark"))
+			label = "VariableMark";
+		return (Mark*) ((QComboBox*) labelEditWidget)->itemData(labelID).value<void*>();
+	}
+	label = ((QLineEdit*) labelEditWidget)->text();
+	if (label == tr("New Mark"))
+		label = "VariableMark";
+	return const_cast<Mark*> (mrk);
+}
+
+void MarkVariableTextDlg::setValues(QString label, QString text)
+{
+	if (labelEditWidget->toolTip() == tr("Edit selected Mark`s label."))
+		((QLineEdit*) labelEditWidget)->setText(label);
+	else
+		((QComboBox*) labelEditWidget)->setCurrentIndex(((QComboBox*) labelEditWidget)->findText(label));
+	textEdit->setText(text);
+}
+
+void MarkVariableTextDlg::changeEvent(QEvent *e)
+{
+	QDialog::changeEvent(e);
+	switch (e->type()) {
+		case QEvent::LanguageChange:
+			retranslateUi(this);
+			break;
+		default:
+			break;
+	}
+}
+
+void MarkVariableTextDlg::onLabelList_currentIndexChanged(int index)
+{
+	if (index > 0)
+	{
+		Mark* mrk = (Mark*) ((QComboBox*) labelEditWidget)->itemData(index).value<void*>();
+		textEdit->setText(mrk->getString());
+	}
+	else
+	{
+		((QComboBox*) labelEditWidget)->setEditText("");
+		textEdit->clear();
+	}
+}
diff --git a/Scribus/scribus/ui/markvariabletext.h b/Scribus/scribus/ui/markvariabletext.h
new file mode 100644
index 0000000..edbbd0b
--- /dev/null
+++ b/Scribus/scribus/ui/markvariabletext.h
@@ -0,0 +1,26 @@
+#ifndef MARKVARIABLETEXT_H
+#define MARKVARIABLETEXT_H
+
+#include "scribusapi.h"
+#include "MarkInsertDlg.h"
+#include "ui_markvariabletext.h"
+
+class SCRIBUS_API MarkVariableTextDlg : public MarkInsertDlg, private Ui::MarkVariableTextDlg
+{
+	Q_OBJECT
+public:
+	explicit MarkVariableTextDlg(const QList<Mark*>&, QWidget *parent = 0);
+	explicit MarkVariableTextDlg(const Mark*, QWidget *parent = 0);
+	~MarkVariableTextDlg();
+	virtual Mark* values(QString& label, QString& text);
+	virtual void setValues(const QString label, const QString text);
+protected:
+	void changeEvent(QEvent *e);
+private slots:
+	void onLabelList_currentIndexChanged(int index);
+private:
+	QWidget* labelEditWidget;
+	const Mark* mrk;
+};
+
+#endif // MARKVARIABLETEXT_H
diff --git a/Scribus/scribus/ui/markvariabletext.ui b/Scribus/scribus/ui/markvariabletext.ui
new file mode 100644
index 0000000..861e05b
--- /dev/null
+++ b/Scribus/scribus/ui/markvariabletext.ui
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MarkVariableTextDlg</class>
+ <widget class="QDialog" name="MarkVariableTextDlg">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>394</width>
+    <height>117</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>0</width>
+    <height>117</height>
+   </size>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>16777215</width>
+    <height>117</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Add new Mark for Variable Text</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="labelLayout">
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Label:</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <widget class="QLabel" name="label_2">
+       <property name="text">
+        <string>Text to insert:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="textEdit"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>202</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QDialogButtonBox" name="buttonBox">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="standardButtons">
+        <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>MarkVariableTextDlg</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>MarkVariableTextDlg</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/Scribus/scribus/ui/notessetmanager.cpp b/Scribus/scribus/ui/notessetmanager.cpp
new file mode 100644
index 0000000..06bda9d
--- /dev/null
+++ b/Scribus/scribus/ui/notessetmanager.cpp
@@ -0,0 +1,562 @@
+#include <QMessageBox>
+
+#include "notessetmanager.h"
+#include "pageitem_noteframe.h"
+#include "prefsmanager.h"
+#include "prefsfile.h"
+#include "scribusdoc.h"
+#include "scribusview.h"
+#include "scribus.h"
+#include "scmessagebox.h"
+
+NotesSetsManager::NotesSetsManager(QWidget *parent, const char *name)
+	: ScrPaletteBase(parent, name), m_doc(NULL)
+{
+	setupUi(this);
+	QString pname(name);
+	if (pname.isEmpty())
+		pname = "notessetsManager";
+	m_prefs = PrefsManager::instance()->prefsFile->getContext(pname);
+
+	setBlockSignals(true);
+	
+	setDoc(0);
+	languageChange();
+	NSlistBox->setInsertPolicy(QComboBox::InsertAlphabetically);
+
+	NumberingBox->addItem("1 2 3");
+	NumberingBox->addItem("i ii iii");
+	NumberingBox->addItem("I II III");
+	NumberingBox->addItem("a b c");
+	NumberingBox->addItem("A B C");
+	NumberingBox->addItem("*");
+
+	RangeBox->addItem(tr("Document"));
+	RangeBox->addItem(tr("Section"));
+	RangeBox->addItem(tr("Story"));
+	RangeBox->addItem(tr("Page"));
+	RangeBox->addItem(tr("Frame"));
+
+	StartSpinBox->setMinimum(1);
+	StartSpinBox->setMaximum(99999);
+	changesMap.clear();
+	addNewNsMode = false;
+
+	setBlockSignals(isVisible());
+}
+
+NotesSetsManager::~NotesSetsManager()
+{
+	storeVisibility(this->isVisible());
+	storePosition();
+	storeSize();
+}
+
+void NotesSetsManager::languageChange()
+{
+	bool wasSignalsBlocked = signalsBlocked();
+	setBlockSignals(true);
+	
+	if (addNewNsMode)
+	{
+		OKButton->setText(tr("Cancel"));
+		OKButton->setToolTip(tr("Dialog is in adding new notes set mode. After pressing Cancel button dialog will be switched into normal notes sets edit mode."));
+	}
+	else
+	{
+		OKButton->setText("OK");
+		OKButton->setToolTip("");
+	}
+	NewButton->setText(tr("Add New Set"));
+	NewButton->setToolTip(tr("New notes set will be add to document only after wpressing Apply butoton.\nYou cannot switch to different notes set before you apply that new one or press Cancel button and exit from adding mode."));
+
+	setBlockSignals(wasSignalsBlocked);
+}
+
+void NotesSetsManager::setDoc(ScribusDoc *doc)
+{
+	bool wasSignalsBlocked = signalsBlocked();
+	setBlockSignals(true);
+	if (m_doc != NULL)
+		disconnect(m_doc->scMW(), SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int)));
+	m_doc = doc;
+	paraStyleCombo->setDoc(m_doc);
+	charStyleCombo->setDoc(m_doc);
+	if (m_doc != NULL)
+	{
+		updateNSList();
+		NSlistBox->setCurrentIndex(0);
+		readNSet(NSlistBox->currentText());
+		setEnabled(true);
+		ApplyButton->setEnabled(false);
+		connect(m_doc->scMW(), SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int)));
+	}
+	else
+	{
+		changesMap.clear();
+		NewNameEdit->clear();
+		setEnabled(false);
+	}
+	setBlockSignals(wasSignalsBlocked);
+}
+
+void NotesSetsManager::handleUpdateRequest(int updateFlags)
+{
+	bool wasSignalsBlocked = signalsBlocked();
+	setBlockSignals(true);
+	if ((updateFlags & reqCharStylesUpdate) || (updateFlags & reqTextStylesUpdate))
+		charStyleCombo->updateFormatList();
+	if ((updateFlags & reqParaStylesUpdate) || (updateFlags & reqTextStylesUpdate))
+		paraStyleCombo->updateFormatList();
+	readNSet(NSlistBox->currentText());
+	setBlockSignals(wasSignalsBlocked);
+}
+
+void NotesSetsManager::updateNSList()
+{
+	bool wasSignalsBlocked = signalsBlocked();
+	NSlistBox->blockSignals(true);
+	if (m_doc == NULL)
+		NSlistBox->setEnabled(false);
+	else
+	{
+		NSlistBox->clear();
+		changesMap.clear();
+		for (int a = 0; a < m_doc->m_docNotesSetsList.count(); ++a)
+		{
+			NSlistBox->addItem(m_doc->m_docNotesSetsList.at(a)->name());
+			changesMap.insert(m_doc->m_docNotesSetsList.at(a)->name(), *(m_doc->m_docNotesSetsList.at(a)));
+		}
+		NSlistBox->setEnabled(true);
+		if (NSlistBox->currentText() != tr("default"))
+			DeleteButton->setEnabled(true);
+		else
+			DeleteButton->setEnabled(false);
+	}
+	NSlistBox->blockSignals(wasSignalsBlocked);
+	
+	DeleteButton->setEnabled(NSlistBox->currentText() != tr("default"));
+}
+
+void NotesSetsManager::setBlockSignals(bool block)
+{
+	foreach (QWidget* obj, findChildren<QWidget *>())
+	{
+		obj->blockSignals(block);
+	}
+	paraStyleCombo->blockSignals(block);
+	charStyleCombo->blockSignals(block);
+}
+
+void NotesSetsManager::setNSet(NotesSet * NS)
+{
+	if (NS == NULL)
+		return;
+	bool wasSignalsBlocked = signalsBlocked();
+	setBlockSignals(true);
+	NSlistBox->setCurrentIndex(NSlistBox->findText(NS->name()));
+	NewNameEdit->setText(NS->name());
+	if (NS->name() == tr("default"))
+		NewNameEdit->setEnabled(false);
+	else
+		NewNameEdit->setEnabled(true);
+	FootRadio->setChecked(!NS->isEndNotes());
+	if (NS->range() == NSRframe)
+		EndRadio->setEnabled(false);
+	else
+		EndRadio->setEnabled(true);
+	EndRadio->setChecked(NS->isEndNotes());
+	NumberingBox->setCurrentIndex((int) NS->getType());
+	RangeBox->setCurrentIndex((int) NS->range());
+	StartSpinBox->setValue(NS->start());
+	PrefixEdit->setText(NS->prefix());
+	SuffixEdit->setText(NS->suffix());
+	SuperMasterCheck->setChecked(NS->isSuperscriptInMaster());
+	SuperNoteCheck->setChecked(NS->isSuperscriptInNote());
+	if (!NS->notesParStyle().isEmpty() && (NS->notesParStyle() != tr("No Style")))
+		paraStyleCombo->setCurrentIndex(paraStyleCombo->findText(NS->notesParStyle()));
+	if (!NS->marksChStyle().isEmpty() && (NS->marksChStyle() != tr("No Style")))
+		charStyleCombo->setCurrentIndex(charStyleCombo->findText(NS->marksChStyle()));
+	AutoH->setChecked(NS->isAutoNotesHeight());
+	AutoW->setChecked(NS->isAutoNotesWidth());
+	AutoWeld->setChecked(NS->isAutoWeldNotesFrames());
+	//for endnotes remove FRAME range (same effect as footnotes for frame)
+	//and disable autofixing size of notes frames
+	int rangeFrameIndex = RangeBox->findText(tr("Frame"));
+	if (NS->isEndNotes())
+	{
+		AutoW->setEnabled(false);
+		AutoWeld->setEnabled(false);
+		if (rangeFrameIndex >= 0)
+			RangeBox->removeItem(rangeFrameIndex);
+	}
+	else
+	{
+		AutoW->setEnabled(true);
+		AutoWeld->setEnabled(true);
+		if (rangeFrameIndex == -1)
+			RangeBox->addItem(tr("Frame"));
+	}
+	AutoRemove->setChecked(NS->isAutoRemoveEmptyNotesFrames());
+
+	ApplyButton->setEnabled(false);
+	setBlockSignals(wasSignalsBlocked);
+}
+
+void NotesSetsManager::readNSet(QString nsName)
+{
+	NotesSet * NS = m_doc->getNS(nsName);
+	setNSet(NS);
+}
+
+void NotesSetsManager::on_NSlistBox_currentIndexChanged(const QString &arg1)
+{
+	if (arg1 != tr("default"))
+		DeleteButton->setEnabled(true);
+	else
+		DeleteButton->setEnabled(false);
+	readNSet(arg1);
+}
+
+void NotesSetsManager::on_ApplyButton_clicked()
+{
+	if (addNewNsMode)
+	{
+		QString newName = NSlistBox->currentText();
+		NotesSet newNS = changesMap.value(newName);
+		if (m_doc->validateNSet(newNS))
+		{
+			addNewNsMode = false;
+			OKButton->setText("OK");
+			ApplyButton->setText(tr("Apply"));
+			m_doc->newNotesSet(newNS);
+			updateNSList();
+			NSlistBox->setCurrentIndex(NSlistBox->findText(newNS.name()));
+		}
+		else
+			return;
+	}
+	else
+	{
+		bool updateNS = false;
+		//remeber current NSet
+		QString currNS = NSlistBox->currentText();
+		NotesSet* NS = NULL;
+		
+		foreach (const QString &nsName, changesMap.keys())
+		{
+			NotesSet n = changesMap.value(nsName);
+
+			if (nsName != n.name())
+			{
+				//new name for existing set
+				QString newName = n.name();
+				getUniqueName(newName, changesMap.keys(),"=");
+				n.setName(newName);
+				NewNameEdit->setText(newName);
+				//current NSet name change
+				if (currNS == nsName)
+					currNS = newName;
+				NS = m_doc->getNS(nsName);
+				m_doc->renameNotesSet(NS, newName);
+				updateNS = true;
+			}
+
+			//validate settings
+			if (!m_doc->validateNSet(n))
+			{
+				NSlistBox->setCurrentIndex(NSlistBox->findText(n.name()));
+				break;
+			}
+
+			//change settings and update marks
+			if (NS == NULL)
+				NS = m_doc->getNS(n.name());
+			if (*NS != n)
+			{
+				//converting foot <--> end notes or changing footnotes range
+				if ((NS->isEndNotes() != n.isEndNotes()) || (NS->isEndNotes() && n.isEndNotes() && NS->range() != n.range()))
+				{
+					foreach (PageItem_NoteFrame* nF, m_doc->listNotesFrames(NS))
+						m_doc->delNoteFrame(nF, true);
+					if (n.isEndNotes())
+						m_doc->flag_updateEndNotes = true;
+				}
+				//after changing automation features for notes set notes frames must must be updated
+				if (NS->isAutoWeldNotesFrames() != n.isAutoWeldNotesFrames())
+					m_doc->flag_notesChanged = true; //notesframes welding must be updated
+				else if (NS->isAutoNotesWidth() != n.isAutoNotesWidth() && n.isAutoNotesWidth())
+					m_doc->flag_notesChanged = true; //notesframes height must be updated
+				else if (NS->isAutoNotesHeight() != n.isAutoNotesHeight() && n.isAutoNotesHeight())
+					m_doc->flag_notesChanged = true; //notesframes width must be updated
+				*NS = n; 
+				updateNS = true;
+				//invalidate all text frames with marks from current changed notes set
+				foreach (PageItem* item, m_doc->DocItems)
+				{
+					if (item->isTextFrame() && !item->isNoteFrame() && item->asTextFrame()->hasMark(NS))
+						item->invalid = true;
+				}
+				m_doc->updateNotesNums(NS);
+				if (m_doc->flag_updateEndNotes)
+					m_doc->updateEndnotesFrames(NS);
+				m_doc->updateNotesFramesStyles(NS);
+				if (m_doc->flag_notesChanged)
+					m_doc->updateNotesFramesSettings(NS);
+			}
+		}
+		if (updateNS)
+		{
+			updateNSList();
+			m_doc->flag_updateNotesLabels = true;
+			//m_doc->notesFramesUpdate();
+			m_doc->changed();
+			m_doc->regionsChanged()->update(QRectF());
+		}
+		//restore NSet index
+		readNSet(currNS);
+	}
+
+	ApplyButton->setEnabled(false);
+	NSlistBox->setEnabled(true);
+	NewButton->setEnabled(true);
+}
+
+void NotesSetsManager::on_DeleteButton_clicked()
+{
+	QString nsName = NSlistBox->currentText();
+	int t = ScMessageBox::warning(m_doc->scMW(), QObject::tr("Attention! Deleting Notes Set"), "<qt>" +
+								 QObject::tr("You are going to delete notes set %1, but you must to know, that it deletes all notes inputs in notes frames and notes marks in text with that notes set.").arg(nsName) + "</qt>",
+								 QMessageBox::Ok, QMessageBox::Abort | QMessageBox::Default);
+	if (t == QMessageBox::Ok)
+	{
+		m_doc->deleteNoteSet(nsName);
+		m_doc->changed();
+		setDoc(m_doc);
+	}
+}
+
+void NotesSetsManager::on_NewButton_clicked()
+{
+	QString oldName = NSlistBox->currentText();
+	NotesSet newNS = changesMap.value(oldName);
+	QString newName = oldName;
+	getUniqueName(newName, changesMap.keys(), "_");
+	newNS.setName(newName);
+	changesMap.insert(newName, newNS);
+	setNSet(&newNS);
+	
+	NewNameEdit->setEnabled(true);
+	NSlistBox->addItem(newName);
+	NSlistBox->setCurrentIndex(NSlistBox->findText(newName));
+	NSlistBox->setEnabled(false);
+	ApplyButton->setText(tr("Add Set"));
+	ApplyButton->setEnabled(true);
+	DeleteButton->setEnabled(false);
+	NewButton->setEnabled(false);
+	addNewNsMode = true;
+	OKButton->setText(tr("Cancel Adding"));
+	OKButton->setToolTip(tr("Notes Set Manager is in adding new notes set mode. After pressing Cancel button Notes Sets Manager switch into normal notes sets edit mode."));
+}
+
+void NotesSetsManager::on_OKButton_clicked()
+{
+	if (OKButton->text() != "OK")
+	{
+		//in adding new set mode go back to normal editing mode
+		OKButton->setText("OK");
+		NewButton->setEnabled(true);
+		addNewNsMode = false;
+		QString newName = NSlistBox->currentText();
+		changesMap.remove(newName);
+		int index = NSlistBox->findText(newName);
+		NSlistBox->removeItem(index);
+		NSlistBox->setCurrentIndex(index-1);
+		on_NSlistBox_currentIndexChanged(NSlistBox->currentText());
+	}
+	else
+	{
+		if (ApplyButton->isEnabled())
+			//apply changes
+			on_ApplyButton_clicked();
+
+		//in normal mode close Notes Sets Manager
+		close();
+	}
+}
+
+void NotesSetsManager::on_NewNameEdit_textChanged(const QString &arg1)
+{
+	NotesSet ns = changesMap.value(NSlistBox->currentText());
+	ns.setName(arg1);
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesSetsManager::on_FootRadio_toggled(bool checked)
+{
+	bool wasSignalsBlocked = signalsBlocked();
+	setBlockSignals(true);
+
+	NotesSet ns = changesMap.value(NSlistBox->currentText());
+	ns.setEndNotes(!checked);
+	changesMap.insert(NSlistBox->currentText(), ns);
+	EndRadio->setChecked(!checked);
+	if (checked)
+	{
+		ns.setAutoNotesWidth(true);
+		AutoW->setEnabled(true);
+		AutoW->setChecked(true);
+		ns.setAutoWeldNotesFrames(true);
+		AutoWeld->setEnabled(true);
+		AutoWeld->setChecked(true);
+	}
+	
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+	setBlockSignals(wasSignalsBlocked);
+}
+
+void NotesSetsManager::on_EndRadio_toggled(bool checked)
+{
+	bool wasSignalsBlocked = signalsBlocked();
+	setBlockSignals(true);
+
+	NotesSet ns = changesMap.value(NSlistBox->currentText());
+	ns.setEndNotes(checked);
+	FootRadio->setChecked(!checked);
+	if (checked)
+	{
+		ns.setAutoNotesWidth(false);
+		AutoW->setChecked(false);
+		AutoW->setEnabled(false);
+		ns.setAutoWeldNotesFrames(false);
+		AutoWeld->setChecked(false);
+		AutoWeld->setEnabled(false);
+	}
+	
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+	setBlockSignals(wasSignalsBlocked);
+}
+
+void NotesSetsManager::on_NumberingBox_currentIndexChanged(int index)
+{
+	NotesSet ns = changesMap.value(NSlistBox->currentText());
+	ns.setType((NumerationType) index);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesSetsManager::on_RangeBox_currentIndexChanged(int index)
+{
+	NotesSet ns = changesMap.value(NSlistBox->currentText());
+	ns.setRange((NumerationRange) index);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesSetsManager::on_StartSpinBox_valueChanged(int arg1)
+{
+	NotesSet ns = changesMap.value(NSlistBox->currentText());
+	ns.setStart(arg1);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesSetsManager::on_PrefixEdit_textChanged(const QString &arg1)
+{
+	NotesSet ns = changesMap.value(NSlistBox->currentText());
+	ns.setPrefix(arg1);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesSetsManager::on_SuffixEdit_textChanged(const QString &arg1)
+{
+	NotesSet ns = changesMap.value(NSlistBox->currentText());
+	ns.setSuffix(arg1);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesSetsManager::on_SuperMasterCheck_toggled(bool checked)
+{
+	NotesSet ns = changesMap.value(NSlistBox->currentText());
+	ns.setSuperscriptInMaster(checked);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesSetsManager::on_SuperNoteCheck_toggled(bool checked)
+{
+	NotesSet ns = changesMap.value(NSlistBox->currentText());
+	ns.setSuperscriptInNote(checked);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesSetsManager::on_AutoH_toggled(bool checked)
+{
+	NotesSet ns = changesMap.value(NSlistBox->currentText());
+	ns.setAutoNotesHeight(checked);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesSetsManager::on_AutoW_toggled(bool checked)
+{
+	NotesSet ns = changesMap.value(NSlistBox->currentText());
+	ns.setAutoNotesWidth(checked);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesSetsManager::on_AutoWeld_toggled(bool checked)
+{
+	NotesSet ns = changesMap.value(NSlistBox->currentText());
+	ns.setAutoWeldNotesFrames(checked);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesSetsManager::on_AutoRemove_toggled(bool checked)
+{
+	NotesSet ns = changesMap.value(NSlistBox->currentText());
+	ns.setAutoRemoveEmptyNotesFrames(checked);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesSetsManager::on_paraStyleCombo_currentIndexChanged(const int &arg1)
+{
+	NotesSet ns = changesMap.value(NSlistBox->currentText());
+	if (arg1 == 0)
+		ns.setNotesParStyle("");
+	else
+		ns.setNotesParStyle(paraStyleCombo->itemText(arg1));
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesSetsManager::on_charStyleCombo_currentIndexChanged(const int &arg1)
+{
+	NotesSet ns = changesMap.value(NSlistBox->currentText());
+	if (arg1 == 0)
+		ns.setMarksCharStyle("");
+	else
+		ns.setMarksCharStyle(charStyleCombo->itemText(arg1));
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
diff --git a/Scribus/scribus/ui/notessetmanager.h b/Scribus/scribus/ui/notessetmanager.h
new file mode 100644
index 0000000..5042c7e
--- /dev/null
+++ b/Scribus/scribus/ui/notessetmanager.h
@@ -0,0 +1,58 @@
+#ifndef NOTESSETMANAGER_H
+#define NOTESSETMANAGER_H
+
+#include "notesset.h"
+#include "ui/scrpalettebase.h"
+#include "ui/spalette.h"
+#include "ui_notessetmanager.h"
+class ScribusDoc;
+class ScribusMainWindow;
+
+class SCRIBUS_API NotesSetsManager : public ScrPaletteBase, private Ui::NotesSetManager
+{
+	Q_OBJECT
+
+public:
+	explicit NotesSetsManager(QWidget *parent = 0, const char *name = "notessetsManager");
+	~NotesSetsManager();
+
+private:
+	ScribusDoc         *m_doc;
+	PrefsContext       *m_prefs;
+	QMap<QString, NotesSet> changesMap; //<NSname to change, NSet new values>
+	void updateNSList();
+	void readNSet(QString nsName);
+	void changeNSet();
+	void setBlockSignals(bool block);
+	bool addNewNsMode;
+
+public slots:
+	void setDoc(ScribusDoc *doc);
+	void handleUpdateRequest(int updateFlags);
+	void languageChange();
+	void setNSet(NotesSet* NS);
+
+private slots:
+	void on_NSlistBox_currentIndexChanged(const QString &arg1);
+	void on_ApplyButton_clicked();
+	void on_DeleteButton_clicked();
+	void on_OKButton_clicked();
+	void on_NewNameEdit_textChanged(const QString &arg1);
+	void on_FootRadio_toggled(bool checked);
+	void on_EndRadio_toggled(bool checked);
+	void on_NumberingBox_currentIndexChanged(int index);
+	void on_RangeBox_currentIndexChanged(int index);
+	void on_StartSpinBox_valueChanged(int arg1);
+	void on_PrefixEdit_textChanged(const QString &arg1);
+	void on_SuffixEdit_textChanged(const QString &arg1);
+	void on_SuperMasterCheck_toggled(bool checked);
+	void on_SuperNoteCheck_toggled(bool checked);
+	void on_AutoH_toggled(bool checked);
+	void on_AutoW_toggled(bool checked);
+	void on_AutoWeld_toggled(bool checked);
+	void on_AutoRemove_toggled(bool checked);
+	void on_NewButton_clicked();
+	void on_paraStyleCombo_currentIndexChanged(const int &arg1);
+	void on_charStyleCombo_currentIndexChanged(const int &arg1);
+};
+#endif // NOTESSETMANAGER_H
diff --git a/Scribus/scribus/ui/notessetmanager.ui b/Scribus/scribus/ui/notessetmanager.ui
new file mode 100644
index 0000000..822f88a
--- /dev/null
+++ b/Scribus/scribus/ui/notessetmanager.ui
@@ -0,0 +1,376 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>NotesSetManager</class>
+ <widget class="QDialog" name="NotesSetManager">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>284</width>
+    <height>500</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>280</width>
+    <height>360</height>
+   </size>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>16777215</width>
+    <height>500</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Notes Sets Manager</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="1" column="0">
+    <layout class="QVBoxLayout" name="verticalLayout">
+     <item>
+      <widget class="QComboBox" name="NSlistBox">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout_2">
+       <item>
+        <spacer name="horizontalSpacer">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>40</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
+        <widget class="QPushButton" name="NewButton">
+         <property name="text">
+          <string>Add New</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <layout class="QFormLayout" name="formLayout">
+       <property name="fieldGrowthPolicy">
+        <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
+       </property>
+       <property name="rowWrapPolicy">
+        <enum>QFormLayout::DontWrapRows</enum>
+       </property>
+       <property name="labelAlignment">
+        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+       </property>
+       <item row="0" column="0">
+        <widget class="QLabel" name="NewNameLabel">
+         <property name="text">
+          <string>New Name</string>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="1">
+        <widget class="QLineEdit" name="NewNameEdit"/>
+       </item>
+       <item row="1" column="0">
+        <widget class="QRadioButton" name="FootRadio">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="text">
+          <string>Footnotes</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="1">
+        <widget class="QRadioButton" name="EndRadio">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="text">
+          <string>Endnotes</string>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="0">
+        <widget class="QLabel" name="NumberinLabel">
+         <property name="text">
+          <string>Numbering</string>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="1">
+        <widget class="QComboBox" name="NumberingBox">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="0">
+        <widget class="QLabel" name="RangeLabel">
+         <property name="text">
+          <string>Range</string>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="1">
+        <widget class="QComboBox" name="RangeBox">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+        </widget>
+       </item>
+       <item row="4" column="0">
+        <widget class="QLabel" name="StartLabel">
+         <property name="text">
+          <string>Start Number</string>
+         </property>
+        </widget>
+       </item>
+       <item row="4" column="1">
+        <widget class="QSpinBox" name="StartSpinBox">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+        </widget>
+       </item>
+       <item row="5" column="0">
+        <widget class="QLabel" name="PrefixLabel">
+         <property name="text">
+          <string>Prefix</string>
+         </property>
+        </widget>
+       </item>
+       <item row="5" column="1">
+        <widget class="QLineEdit" name="PrefixEdit"/>
+       </item>
+       <item row="6" column="0">
+        <widget class="QLabel" name="SuffixLabel">
+         <property name="text">
+          <string>Suffix</string>
+         </property>
+        </widget>
+       </item>
+       <item row="6" column="1">
+        <widget class="QLineEdit" name="SuffixEdit"/>
+       </item>
+       <item row="7" column="0">
+        <widget class="QCheckBox" name="SuperMasterCheck">
+         <property name="text">
+          <string/>
+         </property>
+        </widget>
+       </item>
+       <item row="7" column="1">
+        <widget class="QLabel" name="SuperMasterLabel">
+         <property name="text">
+          <string>Superscript in text</string>
+         </property>
+        </widget>
+       </item>
+       <item row="8" column="0">
+        <widget class="QCheckBox" name="SuperNoteCheck">
+         <property name="text">
+          <string/>
+         </property>
+        </widget>
+       </item>
+       <item row="8" column="1">
+        <widget class="QLabel" name="SuperNoteLabel">
+         <property name="text">
+          <string>Superscript in notes</string>
+         </property>
+        </widget>
+       </item>
+       <item row="9" column="0">
+        <widget class="QLabel" name="charStyleComboLabel">
+         <property name="lineWidth">
+          <number>2</number>
+         </property>
+         <property name="text">
+          <string>Mark`s Character style</string>
+         </property>
+         <property name="textFormat">
+          <enum>Qt::RichText</enum>
+         </property>
+        </widget>
+       </item>
+       <item row="9" column="1">
+        <widget class="CharStyleComboBox" name="charStyleCombo">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+        </widget>
+       </item>
+       <item row="10" column="0">
+        <widget class="QLabel" name="paraStyleComboLabel">
+         <property name="text">
+          <string>Note`s paragraph style</string>
+         </property>
+        </widget>
+       </item>
+       <item row="10" column="1">
+        <widget class="ParaStyleComboBox" name="paraStyleCombo">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+        </widget>
+       </item>
+       <item row="11" column="0">
+        <widget class="QCheckBox" name="AutoH">
+         <property name="text">
+          <string/>
+         </property>
+        </widget>
+       </item>
+       <item row="11" column="1">
+        <widget class="QLabel" name="AutoHLabel">
+         <property name="text">
+          <string>Auto Height</string>
+         </property>
+        </widget>
+       </item>
+       <item row="12" column="0">
+        <widget class="QCheckBox" name="AutoW">
+         <property name="text">
+          <string/>
+         </property>
+        </widget>
+       </item>
+       <item row="12" column="1">
+        <widget class="QLabel" name="AutoWLabel">
+         <property name="text">
+          <string>Auto Width</string>
+         </property>
+        </widget>
+       </item>
+       <item row="13" column="0">
+        <widget class="QCheckBox" name="AutoWeld">
+         <property name="text">
+          <string/>
+         </property>
+        </widget>
+       </item>
+       <item row="13" column="1">
+        <widget class="QLabel" name="AutoWeldLabel">
+         <property name="text">
+          <string>Auto Welding</string>
+         </property>
+        </widget>
+       </item>
+       <item row="14" column="0">
+        <widget class="QCheckBox" name="AutoRemove">
+         <property name="text">
+          <string/>
+         </property>
+        </widget>
+       </item>
+       <item row="14" column="1">
+        <widget class="QLabel" name="AutoRemoveLabel">
+         <property name="text">
+          <string>Remove if empty</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout">
+       <item>
+        <widget class="QPushButton" name="ApplyButton">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="text">
+          <string>Apply</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QPushButton" name="DeleteButton">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="text">
+          <string>Delete</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QPushButton" name="OKButton">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="text">
+          <string>OK</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>CharStyleComboBox</class>
+   <extends>QComboBox</extends>
+   <header>ui/spalette.h</header>
+  </customwidget>
+  <customwidget>
+   <class>ParaStyleComboBox</class>
+   <extends>QComboBox</extends>
+   <header>ui/spalette.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Scribus/scribus/ui/storyeditor.cpp b/Scribus/scribus/ui/storyeditor.cpp
index 42882cb..dc657c0 100644
--- a/Scribus/scribus/ui/storyeditor.cpp
+++ b/Scribus/scribus/ui/storyeditor.cpp
@@ -2893,7 +2893,7 @@ void StoryEditor::updateTextFrame()
 		}
 	}
 #endif
-	currItem->invalidateLayout();
+	currItem->asTextFrame()->invalidateLayout(true);
 	PageItem* nb2 = nextItem;
 	nb2->itemText.clear();
 #if 0
@@ -2941,7 +2941,7 @@ void StoryEditor::updateTextFrame()
 	Editor->saveItemText(nextItem);
 	// #9180 : force relayout here, it appears that relayout is sometime disabled
 	// to speed up selection, but re layout() cannot be avoided here
-	nextItem->invalidateLayout();
+	nextItem->asTextFrame()->invalidateLayout(true);
 	nextItem->layout();
 #if 0
 	QList<PageItem*> FrameItemsDel;
diff --git a/Scribus/scribus/undomanager.cpp b/Scribus/scribus/undomanager.cpp
index 500b22b..c4b1638 100644
--- a/Scribus/scribus/undomanager.cpp
+++ b/Scribus/scribus/undomanager.cpp
@@ -703,6 +703,9 @@ bool TransactionState::contains(int uid) const
 {
 	for (uint i = 0; i < states_.size(); ++i)
 	{
+		//FIX ME: hack - with notes frames it seems not working sometimes
+		if (states_[i]->undoObject() == NULL)
+			continue;
 		if (states_[i]->undoObject()->getUId() == static_cast<uint>(uid))
 			return true;
 	}
@@ -713,6 +716,9 @@ bool TransactionState::containsOnly(int uid) const
 {
 	for (uint i = 0; i < states_.size(); ++i)
 	{
+		//FIX ME: hack - with notes frames it seems not working sometimes
+		if (states_[i]->undoObject() == NULL)
+			continue;
 		if (states_[i]->undoObject()->getUId() != static_cast<uint>(uid))
 			return false;
 	}
diff --git a/Scribus/scribus/util.cpp b/Scribus/scribus/util.cpp
index 0eb0d5e..cc8d85d 100644
--- a/Scribus/scribus/util.cpp
+++ b/Scribus/scribus/util.cpp
@@ -537,27 +537,31 @@ QString getFileNameByPage(ScribusDoc* currDoc, uint pageNo, QString extension)
 	return QString("%1-%2%3.%4").arg(defaultName).arg(QObject::tr("page", "page export")).arg(number, 3, 10, QChar('0')).arg(extension);
 }
 
-const QString getStringFromSequence(DocumentSectionType type, uint position)
+const QString getStringFromSequence(DocumentSectionType type, uint index, QString asterix)
 {
 	QString retVal("");
 	switch( type )
 	{
 		case Type_1_2_3:
-			retVal=QString::number(position);
+			retVal=QString::number(index);
 			break;
 		case Type_A_B_C:
-			retVal=numberToLetterSequence(position).toUpper();
+			retVal=numberToLetterSequence(index).toUpper();
 			break;
 		case Type_a_b_c:
-			retVal=numberToLetterSequence(position);
+			retVal=numberToLetterSequence(index);
 			break;
 		case Type_I_II_III:
-			retVal=arabicToRoman(position);
+			retVal=arabicToRoman(index);
 			break;
 		case Type_i_ii_iii:
 			//well, for lower case people will want that, even if its "wrong"
 			//ie, X=10, x=10000
-			retVal=arabicToRoman(position).toLower();
+			retVal=arabicToRoman(index).toLower();
+			break;
+		case Type_asterix:
+			for (uint a=1; a <= index; ++a)
+				retVal.append(asterix);
 			break;
 		case Type_None:
 			break;
@@ -1124,3 +1128,19 @@ void convertOldTable(ScribusDoc *m_Doc, PageItem* gItem, QList<PageItem*> &gpL,
 	}
 	delete gItem;
 }
+
+void getUniqueName(QString &name, QStringList list, QString separator, bool prepend)
+{
+	if (!list.contains(name))
+		return;
+	int token = -1;
+	QString newName;
+	do {
+		token++;
+		if (prepend)
+			newName = separator + QString::number(token) + " " + name;
+		else
+			newName = name + separator + QString::number(token);
+	} while (list.contains(newName));
+	name = newName;
+}
diff --git a/Scribus/scribus/util.h b/Scribus/scribus/util.h
index 05af300..c62da88 100644
--- a/Scribus/scribus/util.h
+++ b/Scribus/scribus/util.h
@@ -129,7 +129,9 @@ QString SCRIBUS_API getLongPathName(const QString & shortPath);
  */
 QString SCRIBUS_API getFileNameByPage(ScribusDoc* currDoc, uint pageNo, QString extension);
 void SCRIBUS_API sDebug(QString message);
-const QString SCRIBUS_API getStringFromSequence(DocumentSectionType type, uint position);
+//asterix is QString used in numeration when number is presented as few chars, like *, **, *** etc
+//default is '*' but can be used any string
+const QString SCRIBUS_API getStringFromSequence(DocumentSectionType type, uint position, QString asterix="*");
 const QString SCRIBUS_API arabicToRoman(uint i);
 const QString SCRIBUS_API numberToLetterSequence(uint i);
 void SCRIBUS_API parsePagesString(QString pages, std::vector<int>* pageNs, int sourcePageCount);
@@ -152,4 +154,10 @@ void    SCRIBUS_API getDashArray(int dashtype, double linewidth, QVector<float>
 void SCRIBUS_API printBacktrace(int nFrames);
 void SCRIBUS_API convertOldTable(ScribusDoc *m_Doc, PageItem* gItem, QList<PageItem*> &gpL, QStack< QList<PageItem*> > *groupStackT = NULL, QList<PageItem *> *target = NULL);
 
+/*!
+ *\brief
+ * check if name exists in list
+ * if exist then seprator and numbers are pre/append to name while it will be unique
+*/
+void SCRIBUS_API getUniqueName(QString &name, QStringList list, QString separator = "", bool prepend = false);
 #endif
diff --git a/Scribus/scribus/util_text.cpp b/Scribus/scribus/util_text.cpp
index 19431d8..e10422b 100644
--- a/Scribus/scribus/util_text.cpp
+++ b/Scribus/scribus/util_text.cpp
@@ -18,6 +18,7 @@ for which a new license (GPL+exception) is in place.
 
 #include "scribusdoc.h"
 #include "util_text.h"
+#include "serializer.h"
 
 int findParagraphStyle(ScribusDoc* doc, const ParagraphStyle& parStyle)
 {
@@ -50,3 +51,21 @@ int findParagraphStyle(ScribusDoc* doc, const QString &name)
 	assert(false);
 	return -1;
 }
+
+StoryText desaxeString(ScribusDoc* doc, QString saxedString)
+{
+	assert(!saxedString.isEmpty());
+
+	Serializer dig(doc);
+	dig.store<ScribusDoc>("<scribusdoc>", doc);
+	StoryText::desaxeRules("/", dig, "SCRIBUSTEXT");
+	dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
+	dig.parseMemory(saxedString.toStdString().c_str(), saxedString.length());
+
+	StoryText* story = dig.result<StoryText>();
+	assert (story != NULL);
+
+	StoryText res = *story;
+	delete story;
+	return res;
+}
diff --git a/Scribus/scribus/util_text.h b/Scribus/scribus/util_text.h
index 8e43470..281a116 100644
--- a/Scribus/scribus/util_text.h
+++ b/Scribus/scribus/util_text.h
@@ -13,6 +13,7 @@ for which a new license (GPL+exception) is in place.
 #include "styles/charstyle.h"
 #include "styles/paragraphstyle.h"
 #include "scribusapi.h"
+#include "text/storytext.h"
 
 class  ScribusDoc;
 
@@ -21,5 +22,7 @@ int SCRIBUS_API findParagraphStyle(ScribusDoc* doc, const ParagraphStyle& parSty
 int SCRIBUS_API findParagraphStyle(ScribusDoc* doc, const QString &name);
 #endif
 
+// returns StoryText from saxed string
+StoryText SCRIBUS_API desaxeString(ScribusDoc* doc, QString saxedString);
 
 #endif
diff --git a/debug b/debug
new file mode 100755
index 0000000..b439717
--- /dev/null
+++ b/debug
@@ -0,0 +1,16 @@
+#!/bin/bash -e
+#export CXXFLAGS="-fopenmp"
+#export CFLAGS="-fopenmp"
+#export CPPFLAGS="-fopenmp"
+
+#export OMP_NUM_THREADS=4
+#alias g++='g++ -fopenmp'
+#alias gcc='gcc -fopenmp'
+cd BUILD
+bdir=`pwd`;
+echo "$bdir";
+IDIR=${bdir//BUILD/INSTALL};
+echo "$IDIR";
+cmake ../Scribus -DCMAKE_INSTALL_PREFIX:PATH="$IDIR" -DWANT_DEBUG=1 -DWANT_GRAPHICSMAGICK=1 -DWANT_VERSIONING=0 -DWANT_NO_EXAMPLES=1 -DWANT_NO_TEMPLATES=1 -DWANT_NOHEADERINSTALL=1 -DWANT_GUI_LANG=pl_PL
+make -j4
+make install -j4
footnotes.diff (360,424 bytes)   

cezaryece

2012-06-21 13:43

updater   ~0028250

Craig, I upload new version of patch against current trunk and some hotfix. Please review again.

ale

2012-06-24 06:18

manager   ~0028280

sunday morning, reading a book and, after a long time, stumbling on a real footnote...

i think that we really need footnotes areas that grow upwards. otherwise, you won't be able to write longer books...

there should probably be arule to break the footnote area on several pages (not trivial: there must be reason why word manages to put the footnote on the wrong page...)

we can try to copy the way libre office does, or ask somebody on the ML who uses footnotes to write a specification...

the second thing that stroke my mind -- and which i don't think is already implemented: there sould be a rule defining when the numbering gets restarted: each frame, a chain of frames, a page, or section (it could already be there... i can' test right now...)

cbradney

2012-06-24 08:17

administrator   ~0028281

ale, do you want me to put this in trunk yet?

JLuc

2012-06-24 20:23

developer   ~0028290

Hello cz,

I managed to install and compile your git version and please find thereafter a couple of requests or bugreports. I began to create independant reports but was told not to so i move them here.

========
"0010795: handles should not appear to resize unresizeable notes welded frame"

Its not possible to resize footnotes frame. That's fine, since it has the same size as the main text frame, and the designed way is to resize main text frame.

Thus, footnotes frames should not display handles to resize them, when selected.
========
"0010794: footnote text-reflow when main text frame's width change"

When the main text frame's width changes, the footnote welded frame width changes accordingly, cool,
BUT the text inside it is not reflown (relayedout).

JLuc

2012-06-24 21:32

developer   ~0028294

More reports about deleting :

- deleting a maintext frame having footnotes, a dialog appears "do you want to delete whole note(s)". I think this question should be rephrased.

- if i answer yes then most of the time the frame is not deleted as it should be and nothing happen. However, it is correctly deleted if there is one note as the last characted in the frame.

JLuc

2012-06-24 21:35

developer   ~0028295

Deleting text containing a note :
when one selects some text containing a notecall or plainly deletes a notecall, the same question appears "do you want to delete whole note(s)" and if "yes", the the deleted text is replaced with white, but text is not reflown, and after some refresh it appears that it has not been deleted.

JLuc

2012-06-24 21:39

developer   ~0028296

addendum to the previous report :
when trying to delete text containg a notes, the following appear in the terminal that has launched scribus :
storytext::charstyle: access at end of text %i 40
storytext::charstyle: access at end of text %i 1

cezaryece

2012-06-27 09:16

updater   ~0028310

I have fixed issues reported above, but I have notice big impact to footnotes feature from text undo, so we should wait with merging footnotes branch for stabilize of Chelen`s work.
I the meanwhile you can check git branch what is done already and how it works.

pygmee

2012-10-20 21:05

developer   ~0029059

cezaryece, wouldn't it be better to put Marks manager as a dockable window. Edit usually have window to predefine ressources not to manage their usage in the document

cezaryece

2012-12-03 11:53

updater   ~0029311

Commited, fixed.

Issue History

Date Modified Username Field Change
2012-06-04 09:54 cezaryece New Issue
2012-06-05 14:48 ale Note Added: 0028081
2012-06-05 21:51 cezaryece Note Added: 0028092
2012-06-06 06:38 ale Note Added: 0028094
2012-06-06 07:15 cbradney Note Added: 0028097
2012-06-06 09:37 cezaryece Note Added: 0028098
2012-06-06 12:34 ale Note Added: 0028101
2012-06-18 06:33 ale Relationship added child of 0003349
2012-06-18 09:17 cezaryece Note Added: 0028181
2012-06-18 09:17 cezaryece File Added: footnotes.diff
2012-06-21 13:41 cezaryece File Deleted: footnotes.diff
2012-06-21 13:41 cezaryece File Added: footnotes.diff
2012-06-21 13:43 cezaryece Note Added: 0028250
2012-06-21 13:44 cezaryece Assigned To => cbradney
2012-06-21 13:44 cezaryece Status new => assigned
2012-06-24 06:18 ale Note Added: 0028280
2012-06-24 08:17 cbradney Note Added: 0028281
2012-06-24 20:23 JLuc Note Added: 0028290
2012-06-24 21:32 JLuc Note Added: 0028294
2012-06-24 21:35 JLuc Note Added: 0028295
2012-06-24 21:39 JLuc Note Added: 0028296
2012-06-27 09:16 cezaryece Note Added: 0028310
2012-10-20 21:05 pygmee Note Added: 0029059
2012-12-03 11:53 cezaryece Note Added: 0029311
2012-12-03 11:53 cezaryece Status assigned => closed
2012-12-03 11:53 cezaryece Resolution open => fixed
2012-12-03 11:53 cezaryece Fixed in Version => 1.5.0svn