Skip to content

Commit

Permalink
1335 all the tocs (part 1) (stevencohn#1509)
Browse files Browse the repository at this point in the history
* stevencohn#1335 all the tocs

* Fix auto-height resize image

* comm

* dialog

* options

* qwe

* PageTocGenerator

* refactored, parity with 6.5.0

* refresh

* (c)

* increment section refresh

* refresh section

* notebook TOC refresh

* np

* para

* refresh existing

* delogger

* fix meta name omTableOfContents

* Proper logging, because I like to make Jason happy

* comments

* fix spelling

* limit page TOC to single per page (step 1)

* BodyOutlines

* prevent replay of HashtagCommand from TaggedCommand

* RemoveTagCommand should ignore tag bank

* obsolete comment
  • Loading branch information
stevencohn authored Jul 29, 2024
1 parent 489b76b commit 6b811fb
Show file tree
Hide file tree
Showing 41 changed files with 1,692 additions and 937 deletions.
5 changes: 3 additions & 2 deletions OneMore/Commands/Clean/RemoveTagsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace River.OneMoreAddIn.Commands


/// <summary>
/// Removes all tags from the current page, except those that are associated with reminders.
/// Removes all tags from the current page, except from the tag bank and those
/// associated with reminders.
/// </summary>
internal class RemoveTagsCommand : Command
{
Expand All @@ -22,7 +23,7 @@ public RemoveTagsCommand()
public override async Task Execute(params object[] args)
{
await using var one = new OneNote(out var page, out var ns);
var tags = page.Root.Elements(ns + "Outline").Descendants(ns + "Tag").ToList();
var tags = page.BodyOutlines.Descendants(ns + "Tag").ToList();
if (!tags.Any())
{
return;
Expand Down
6 changes: 2 additions & 4 deletions OneMore/Commands/CommandFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public CommandFactory(
// otherwise closing the primary or last-used active window will leave owner
// set to an invalid window handle
await using var one = new OneNote();
// convert the ulong to a IWin32Window which will be used by ShowDialog calls
var owner = new Win32WindowHandle(new IntPtr((long)one.WindowHandle));
var owner = one.OwnerWindow;

command.SetFactory(this)
.SetLogger(logger)
Expand Down Expand Up @@ -105,8 +104,7 @@ private async Task Run(string note, Command command, params object[] args)
// otherwise closing the primary or last-used active window will leave owner
// set to an invalid window handle
await using var one = new OneNote();
// convert the ulong to a IWin32Window which will be used by ShowDialog calls
var owner = new Win32WindowHandle(new IntPtr((long)one.WindowHandle));
var owner = one.OwnerWindow;

command.SetFactory(this)
.SetLogger(logger)
Expand Down
5 changes: 1 addition & 4 deletions OneMore/Commands/Edit/AlterSizeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ public override async Task Execute(params object[] args)

var count = AlterQuickStyles(page);

foreach (var outline in page.Root
.Elements(ns + "Outline")
.Where(e => !e.Elements(ns + "Meta")
.Any(m => m.Attribute("name").Value == MetaNames.TaggingBank)))
foreach (var outline in page.BodyOutlines)
{
count +=
AlterByName(outline) +
Expand Down
6 changes: 1 addition & 5 deletions OneMore/Commands/Page/ArrangeContainersCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,7 @@ private bool ArrangeFlow(int columns, int pageWidth)
// after Update for some reason.
private IEnumerable<XElement> CollectContainers(Page page, XNamespace ns)
{
var outlines = page.Root.Elements(ns + "Outline")
.Where(e => !e.Elements(ns + "Meta")
.Any(m => m.Attribute("name").Value == MetaNames.TaggingBank))
.ToList();

var outlines = page.BodyOutlines.ToList();
if (outlines.Count < 2)
{
// zero or one Outline; don't leave the page entirely empty
Expand Down
6 changes: 2 additions & 4 deletions OneMore/Commands/References/CopyLinkCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ public override async Task Execute(params object[] args)

if (specific)
{
var selected = page.Root.Elements(ns + "Outline")
.Where(e => !e.Elements(ns + "Meta")
.Any(m => m.Attribute("name").Value.Equals(MetaNames.TaggingBank)))
var selected = page.BodyOutlines
.Descendants(ns + "OE")
.LastOrDefault(e => e.Attributes().Any(a => a.Name == "selected"));

Expand Down Expand Up @@ -90,7 +88,7 @@ public override async Task Execute(params object[] args)
}
else
{
hyperlink = one.GetHyperlink(page.PageId, null);
hyperlink = one.GetHyperlink(page.PageId, page.TitleID);
}

if (string.IsNullOrEmpty(hyperlink))
Expand Down
5 changes: 1 addition & 4 deletions OneMore/Commands/References/EmbedSubpageCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,7 @@ private async Task<SourceInfo> GetSource(string sourceId, string linkId)
}
}

var outRoot = source.Root.Elements(source.Namespace + "Outline")
.FirstOrDefault(e => !e.Elements(ns + "Meta")
.Any(m => m.Attribute("name").Value == MetaNames.TaggingBank));

var outRoot = source.BodyOutlines.FirstOrDefault();
if (outRoot is null)
{
// couldn't find an Outline but page may contain other valid content items
Expand Down
6 changes: 1 addition & 5 deletions OneMore/Commands/References/LinkReferencesCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,7 @@ private IEnumerable<XElement> FlattenPages(XElement results, string pageId)

private string GetSynopsis(Page page, string title)
{
var body = page.Root
.Elements(ns + "Outline")
.FirstOrDefault(e => !e.Parent.Elements(ns + "Meta")
.Any(m => m.Attribute("name").Value.Equals(MetaNames.TaggingBank)));

var body = page.BodyOutlines.FirstOrDefault();
if (body == null)
{
return null;
Expand Down
5 changes: 1 addition & 4 deletions OneMore/Commands/Reminders/ReportRemindersCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,7 @@ private async Task<string> FindReport(OneNote.Scope scope)

private void ClearContent()
{
var chalkOutlines = page.Root.Elements(ns + "Outline")
.Where(e => !e.Elements(ns + "Meta")
.Any(m => m.Attribute("name").Value == MetaNames.TaggingBank));

var chalkOutlines = page.BodyOutlines;
if (chalkOutlines.Any())
{
// assume the first outline is the report, reuse it as our container
Expand Down
Loading

0 comments on commit 6b811fb

Please sign in to comment.