Saturday, July 25, 2009

New features and a better code organization

After fixing the obvious UI issues, I had some time to concentrate on the actual feature! :)
After fixing the bug with the shell state which was making the forward button block the shell and the cursor disappear, and fixing the back button that showed only text, and no icon, I started expanding the feature to support insertion of the header/footer, footnotes, and internal hyperlinks.

This made me go all the way back to remember examining the feature and the things that happen in the similar programs (mainly M$ Word). At Caolan's suggestion, we added the support for the navigation buttons to remember the position before the first jump, which alone made the navigation feature much better than the one in Word 2007.

Aiming to add the support for the internal links, I started moving the functionality from the GotoContent() method to the lower level, more specific ones, e.g. GotoBookmark, etc.
I got completely stuck realizing that some of the methods for moving around the document are not located in SwWrtShell, where the navigation class was initially put. The first idea was to move the navigation manager up the class hierarchy, preferably SwCrsrShell, where a lot of the Goto* methods are. This was, unfortunatelly, impossible, because of the methods called on SwView that are used to fix the UI issues.

While believing that all the Goto* methods are in SwWrtShell/SwCrsrShell, there was an idea to somehow connect the two. Unfortunately, there were methods needed for the navigation located in SwFEShell.

The great idea Caolan suggested was to implement the extension of the Goto* methods in the SwWrtShell, without moving the navigation class, in which I could keep track of the navigation history and than call the superclass Goto* methods. Due to dynamic binding, whenever navigating from the Writer shell, these methods will be called and besides their usual function, keep track of the navigation history.

I took some time to realize for which components I need to have the history supported outside the Navigator. Firstly I concentrated on the components that can be used as internal links:




Eventually I ended up moving everything in the more specific Goto* methods, even if they aren't called from anywhere else other than the Navigator (i.e. it's GotoContent() method).
That way the navigation history will be supported for some of the features which are yet to be implemented.

I also added the method that adds the current position of the cursor to the navigation history. I realized that's a routine I've repeated more than twice. I left the one that adds a specific position - it might be handy when a navigation to a feature fails for some reason. I haven't yet succeeded in simulating such an event, but I think that I might come upon it during more thorough testing.

There was also a bug when navigating to images: navigation *to* images was working perfectly, selecting the image like when going from Navigator. When one would try to navigate *from* an image, a cursor would disappear and buttons would become disabled. This can be fixed by working with a shell in standard mode.

Since there was a lot of strange illogical behaviour of these buttons in Microsoft Word, I'm going to dedicate a next few days to try and avoid similar situations.

Saturday, July 11, 2009

Navigation buttons working!

Finally! Even though one of the buttons is still as text, after hours and hours of debugging, the buttons seem to work - and also do what they're supposed to do...
The forward button can be a bit buggy, as well as the icons: only when you click within the document, are the icons refreshed...

It turned out I had several bad ideas when I was designing the idea...apparently it was impossible to keep an array of SwPosition* copied from the current cursor - the actual SwPosition-s had to be copied...

Now I'm going to concentrate on testing - what if the position we want to jump to is deleted, what about the external links, etc.

Thursday, July 9, 2009

Strange toolbar



Finally I gave up on rebuilding individual modules and deleting certain directories, and did a full rebuild in order to get the buttons to appear - still can't find the cause of this.
Strangely - even though the code for the back and forward buttons is the same, the names of the images are equivalent, the back button appears as text in the toolbar, and the forward button appears as an icon.
However, you can see both of the icons in the 'visible buttons' menu.

I managed to do a debug build and I'm currently debugging the actual feature. Yeeey, finally! :)

Wednesday, July 8, 2009

Applying git patches

I had some problems applying my patches - the patch complained about files not being found. I tried using git apply and "patch -p0"
I also tried the "patch -p2" because I noticed the "a/" and "b/" prefixes to the names of folders.
What should be done when applying patches created by git diff, you should use
patch -p1
This command should be run from the e.g. build/ooo310-m14 folder
This was one option I didn't try, thinking p1 would cut the "a" and then navigate to my root folder. Strangely, the -p1 option is the way to go :)

This removes the dummy "a/" and "b/" names of folders.

Hope this saves someone a few hours of manually editing the files :)

Packages to install on Ubuntu Jaunty 9.04 for hassle-free ooobuild

I've recently had a fresh install of Ubuntu 9.04 to my new Mac. Here's a list of packages that *cover* the hassle-free build of ooo
the configure command with options was:
./autogen.sh --with-distro=Debian --disable-kde --disable-build-mozilla --disable-binfilter --disable-mono

What is tricky when finding the missing packages, is that the package you need is usually prefixed with a 'lib' to the output you get from configure, and the package you need has a '-dev' suffix.
Example: you need a 'xul' package - it will be named libxul-dev or similar.
The trouble is that search in Synaptic isn't really good, so it can be hard to find these packages entering just, e.g. xul

You can find a list of packages to install on this link:
http://pastebin.com/f499485b8
You can click 'download' and get the text file of these
I believe that using this command:
http://pastebin.com/m7116184d
all of those packages can be installed automatically
I haven't tried it - but it might work. It's just all the package names passed to the apt-get install.
There might be unnecessary packages in this list - but there shouldn't be many. If you don't mind trading a bit of disk space for a few hours of hassle, than this is the thing for you :)

Tuesday, June 30, 2009

Missing parts inserted - but no progress

With a little help from my friends :), I realised there are some parts missing to creating the icons for the toolbar: this is what you need to do if you're going to insert custom icons! I can't guarantee this works, since I see no buttons what so ever, but everybody is suggesting the same thing:
- you have to insert the following code:

<prop oor:name="Properties" type="xs:int">
<value> 1 </value>
</prop>

in e.g. WriterCommands.xcu file, under the part that defines the toolbar button, to enable the icon to appear.

When that is done, you need 4 images (or 4 copies of one image :) ) put into the src/icons/ and src/icons/tango folders. The images name should derive from the name of your command, e.g. if your command is NavigateBack, the names of the files should be lc_navigateback.png, lch_*, sch_* and sc_*

The module that should also be rebuilt is packimages.

If this doesn't work, try reinstalling. If that doesn't work, try purging the user config directory (~/.openoffice.org/3/user/config)

I think I have some serious build problems, because some things behave very diferently on my distro comparing to Cedric's.
I'm trying killing and rebuilding individual modules, and I shall have to try full rebuild if that doesn't work.

Possible things that I still haven't tried:

Cedric suggested to add an entry to sfx2/source/appl/workwin.cxx file, describing the navigationobjectbar. This is not the first time I encounter that there should be some (probably five-digit) number somehow connected to the toolbar I'm trying to make. I thought that the number would be generated by combining SFX_INTERFACE_SW_START and a small constant, but I realised it's just 250, and the numbers I see for other toolbars are usually around 23000 for writer. I guess that the numbers associated with the commands I make is generated by combining the FN_EXTRA2 and SID_SW_START - and those *are* around 20k...maybe I'm getting the concept of these IDs completely wrong? I've got this posted to the mailing list, hoping for some feedback :)

The other option I will also try before full rebuild, is adding the buttons to the standard toolbar instead of creating my own one.

Any help for creating the actual toolbar is highly appreciated! :)

Friday, June 26, 2009

Ghost buttons

Good news! Apparently Cedric can see my buttons! I understand there's something majorly wrong with my build, so I'm going to build it from scratch on Monday, when my new MacBook should be arriving...that might be interesting - installing ubuntu to a macbook, or building in MacOs? Must investigate...

I'm going away during the weekend, but I plan to take some time and examine how the icons are set - that might give me an idea of some of the things I'm missing when setting up the buttons.
I found a method that creates a button, and a class that describes it - my guess is that xml files are examined, this method is called when building, and that's how the buttons are created. I have this idea because I found various plugins that add/change the buttons - and I don't believe they're editing the code.

I'll post the details as soon as I find them reliable :)