[r159239] Lots of iCloud work, document picker performance/animation, fixes merged from internal branches

Configurations:
  - Default to 10.7 deployment target, though the framework code still supports setting this back to 10.6

OWF:
  - Disabled cookie writing for now since it hasn't been ported to 10.7 and isn't used in the (few) internal OWF clients

OmniAppKit:
  - Avoid returning implementation details windows in AppleScript ordered windows
  - Fix bug where date picker window could get stuck behind Mail popped up in full screen mode (via OmniFocus Quick Entry)
  - Moved OADocument into its own group
  - Preserve global variables between script runs in OAScriptToolbarHelper
  - Fixed method swizzle for NSTableView(OAExtensions) dragging support, though it should really be removed
  - Add support for -supplementalTargetForAction:sender: in our target/selection extension
  - Add support for non-monolithic menu/toolbar validation like:

	   - (BOOL)validateToggleFooMenuItem:(NSMenuItem *)item;
	   - (BOOL)validateToggleFooToolbarItem:(NSToolbarItem *)item;
	   - (BOOL)validateToggleFoo:(id <NSValidatedUserInterfaceItem>)item;

    This lets you place the validation logic next to the action implementation
  - Fix some -Wshadow warnings

OmniFileStore:
  - Move document store, file/group items and support here from OmniUI (with lots of fixes/extensions)

OmniFoundation:
  - Added some UTI lookup helpers that prefer types exported by the calling app.
  - Added a convenience class, OFDynamicStoreListener, for subscribing to SCDynamicStore notifications. (hostname changes, computer name changes, etc.)
  - Added OFCompletionMatch (the model portion of OmniFocus's quick project and context matching)
  - Added OFIndexPath; a simplified NSIndexPath that avoided some early bugs in the NS version for high-use cases. May be able to get rid of it in 10.7.
  - OFMutableKnownKeyDictionary returns MKKDs now instead of plain dictionaries for -{mutableC,c,}opyWithZone:
  - Added OFRandomStateDuplicate() and OFRandomNextStateN().
  - Fixed bug in -[OFPreference _refresh] that would prevent it from refreshing.
  - Implemented -[NSMutableAttributedString replaceString:withString:inRange:].
  - Added OFLocalHostName to explicitly get the local (bonjour) hostname even when we have a FQDN.
  - OFHostName no longer caches the result, since the hostname can change during the life of the application.
  - Fixed some memory leaks in OFRelativeDateParser, made it handle abbreviations/full terms in other locales more reliably, handle diacriticals entered as ASCII
  - Add more support for 10.7 security APIs. Fix some unit tests to expect to fail on Lion and/or use the 10.6 API where needed while Apple fixes Radars.
  - Register .defaults files for the frameworks/libraries before any Info.plist entries for defaults from the main app. This allows iOS apps to override framework defaults.

OmniQuartz:
  - Handle shape layers when exporting a layer tree as vector output.
  - Added some more rounded rect variants.

OmniSoftwareUpdate:
  - Only track application active time, not running time. The latter has become impossible to track reliably with apps that adopt Lion's app life cycle.
  - One software update item can now supersede another when it's on a more stable software update track.
  - Fixed automatic selection of the latest update in the table view.
  - Converted nibs to xibs

OmniUI:
  - Moved document store, file/group items out to OmniFileStore.
  - Explicitly send -changeColor: up to targets instead of depending on targeting nil. The behavior of this changed in iOS 5 so that it doesn't proceed from the event receiver, but the windows first responder (seemingly).
  - Added support for keyboard accessory views on OUIInspectorTextWell and OUIEditableFrame
  - Fixed overlap of text and left/right views in centered text alignment in OUIInspectorTextWell.
  - Stacked slices inspector now allows multiple vertically resizable slices, splitting the space between them
  - Improved the document export sheet's selection of types to show
  - Changed parent view used to host text editor controls.
  - Much improved speed and lots of bug fixes to the document picker
  - Added OUICompletionMatchCell from OmniFocus for iOS.
  - Lots more iCloud work in the document picker. Still more to go, some waiting for Radar fixes.
  - Tons of other minor fixes and enhancements
  - Better handle documents and zipped documents document interaction "Inbox" directory
  - Updated action sheet and app menu to use the same block-based action approach

OmniUnzip:
  - Added -URLByWritingTemporaryCopyOfTopLevelEntryNamed:error:.
Moved OmniUnzip before OmniFileStore since OFS depends on OmniUnzip now.
[r161025] Document picker polish and performance and various other fixes.

Configurations:
  - A few minor tweaks for Xcode 4.3.
  - Add -DDEBUG and -DDEBUG_$(USER) to INFOPLIST_PREPROCESSOR_DEFINITIONS.

Overall:
  - Fix up new warnings from Xcode 4.3.
  - Start using the 'context' passing KVO remove method when available.

OmniBase:
  - Fixed System framework detection for Xcode 4.3.
  - Rewrote OBFinishPorting macros so they emit a string with a specific
    format into the executable. This allows searching for all uses with:

      strings MyApp.app/MyApp | grep OBFinishPorting

OmniFoundation:
  - Added OFCheckForInstruments() and make OFObject abort if inline retain
    counts are on while Instruments is trying to track retains.
  - Fix parsing for ICU date formats that have quoted dots as literals.
  - Weakly link new Security.framework symbols for 10.6 compatibility
  - Added block-based helper to OFXMLElement -addElement:childBlock:

OmniFileStore:
  - Fixed a bug in OFSDAVOperation where it would stream error content
    from HTTP errors to its target as though it were normal content.
    - Added block-based asynchronous read/write APIs to OFSFileManager.
  - Added user default for disallowing our uses of iCloud support completely.
  - Rewrote uniquification of file names to be done on the action queue,
    locale/case insensitive.
  - Added a OFSDocumentStoreScope wrapper object instead of an enum so we can
    better support multiple ubiquitous scopes.
  - Updated many OFSDocumentStore methods to take OFSDocumentStoreScope
    parameters where needed.
  - Removed file coordination over whole Documents directory since coordinated
    reads of parent directories don't block anything useful.
  - Fixed up issues with document renaming
  - Added more support for avoiding full rescans of containers when just
    adding a single file.
  - Only create file items on the main queue, serializing possible updates
    from background actions.
  - Deal with missing public UTI for zip more reliably.
  - Moved OFSDocumentStoreFilter from OmniUI.

OmniQuartz:
  - CALayer animation logging can be configured on a per layer tree basis
  - Added helpers for caching/flattening/scaling CFImageRefs

OmniAppKit:
  - Fixed #ifdef guarding use of -supplementalTargetForAction:sender:.
  - Make OAFindController's outlets retained.
  - Added NSError support in OAScriptToolbarHelper/OAWorkflow.
  - Improved default indicator buttons and added a new (x) image.
  - Added -eachAttachment: block iterator to NSAttributedString.
  - Added NSNib utility methods to help transition to more reasonable retain
    semantic methods can the old NSBundle methods.
  - Switched some callers to new NSNib helper methods.
  - Fixed bug in OAFontDescriptor with changing family name on a descriptor
    with implied symbolic attributes.
  - Added OAToolbarItem -menuFormRepresentation for target selection.

OmniInspector:
  - Better handle automatic termination for writing inspector preferences

OmniUI:
  - Re-added images that got accidentally removed
  - Fixed some leaks
  - Updated keyboard avoidance handling to deal better with iOS 5.1
  - Stacked slices inspectors scroll the first responder into view when the
    keyboard appears/disappears
  - Stacked slices inspectors validate available slices more consistently
  - Document closing activity indicator color can be customized by the
    document view controller
  - Handle more types of NSErrors when displaying them.
  - Added a default tools toolbar item icon
  - The document store now tells its delegate when an item moved; we move the
    cached previews rather than regenerating them
  - Preview generation is now asynchronous with completion handlers, allowing
    more of it to run on a background queue
  - Preview image compression and writing is now done on a background queue to
    keep the UI interactive
  - Better handle possible crashes in preview generation so we end up with a
    placeholder on the next run, rather than crashing again on the next run
    (should this ever happen).
  - Add a background task while generating a preview so we finish and close
    the document (lowering our memory use while backgrounded). This also
    avoids weird race conditions with UIDocument closing and activating when
    the document is deleted in the backgrounded interval
  - Report better errors when attempting to open a document that has
    disappeared (since iTunes writes don't provoke NSFilePresenter/Coordinator
    right now, sadly).
  - Deal with oddity in UIDocument where a failed open leaves the document
    still as a file presenter -- closing the "not open" document fixes it.
  - Prefer to generate previews for files that are scrolled into view, making
    preview generation feel faster
  - Use OFSDocumentStoreFilter to control the visible documents in the picker.
  - Moved the edit/drag recognizer to the document picker scroll view, now
    that we have two of them.
  - Fixed animation/flicker in various duplicating/renaming cases.
  - Fix updating of the document title toolbar item when renaming documents
    while they are open.
  - Improve document picker animation when rotating the device
  - Duplicate previews when duplicating files rather than generating them by
    loading the file
  - Add a confirmation menu when duplicating more than one document at a time
  - Disable all the support for document picker folders for now
  - Preview generation uses the improved OQ functions for caching flattened
    images (meaning they are fully read and rendered off disk). Important for
    performance and so CGImageRef doesn't get confused if we rename a preview
    file due to the document file being renamed.
  - Preview caching tries to deal with /var/mobile vs /var/private/mobile in a
    more reliably way.
  - Document renaming now handles hardware, split, undocked keyboards better
    when transitioning between states and rotating.
  - Improved document renaming view layout and rotation handling
  - Added returnKeyType support to OUIEditableFrame
  - Added OUIEditableFrameTextDid{BeginEditing,EndEditing,Change}Notification
  - Fixed possible zombie when changing a text attribute over multiple spans
  - Moved the selection loupe to the root view controller's view rather than
    the window, lest it be in the wrong coordinate system.
  - Release the text inspector when it isn't in use -- it isn't used that
    often and this lowers our memory use.
  - Made tapping on OUIEditableLabeledValueCell easier (for example, in
    WebDAV/iDisk setup text fields)
  - Crossfade the non-document portions of the screen when opening/closing
    documents.
  - Fixed renaming of open documents via the file name toolbar item
  - Improved reliability of Inbox handling and zip extraction when files are
    tapped on in Mail
  - Fixed issues with downloading wrappers from WebDAV

TextEditor sample:
  - Fix document open/close animation rects
  - Fixed leaks
  - Fixed sizing of the document title toolbar item
  - Updated for new preview generation API. Added comments for developers
    doing so in their own apps.
[r161044] Cloud setup icon didn't have the same padding as the other gear menu items.
[r161299] OUIDocumentPicker no longer tries to drive preview cache
  updating/flushing based on UIApplication lifecycle notifications.
  This introduces a race/ordering indeterminacy with OUIAppController.
  Now OUIAppController does it with the proper sequenced completion handlers
  (it was already doing it in the initial app startup case).

[r161133] Added a new OFSDocumentStoreFileItemFinishedDownloadingNotification
  notification. Catch this in OUISingleDocumentAppController. Rename
  -[OUIDocumentPreviewGenerator fileItemContentsChanged:] to
  -fileItemNeedsPreviewUpdate: since it can be called for a couple reasons.

[r161146] Split -[UIDocument scheduleAutosave] into two methods,
  -viewStateChanged and -beganUncommittedDataChange, which better indicate the
  reasons the caller might want to autosave. These also do different things
  now.

  We don't want to call -[UIDocument updateChangeCount:] directly when using
  NSUndoManager-based autosave support since the following pattern:

    - make a real change (dirty)
    - wait for autosave (not dirty)
    - make a view state change (dirty)
    - undo (not dirty, but previous change undone)

  would make UIDocument think it had no changes when it really did.

  Now, OUIDocument keeps track of a view state version counter. It is
  incremented each time -viewStateChanged is called and UIDocument's change
  tracking methods have been subclassed to read/update the counter. UIKit
  calls -hasUnsavedChanges when closing a document or backgrounding the app,
  even if the NSUndoManager-based system hasn't started an autosave.
  This means view state changes will not provoke an autosave (which is nice),
  but they'll participate in autosave if it happens (also nice) and will get
  saved at shutdown time (mostly nice, except for the possibility of spurious
  iCloud conflicts due to view state changes).

  Longer term, we should move view state out of the main file entirely.
  There are maybe a few extra changes we can make to reduce the spurious
  conflicts w/o changing the file format yet.
  See <bug:///75660> (Think about editor state changes and iCloud conflicts).

[r161147] We now dismiss popovers in the document view when changes come in
  via iCloud. To prevent a crash and data loss, iCloud documents must be fully
  downloaded locally before we allow them to be removed from iCloud.
  We now only show the 'Move out of iCloud' menu option if the file is fully
  downloaded. Fixed crasher when a button on the bottom toolbar was being
  pressed at the same time a change comes in from iCloud. We now keep track of
  the document's editingEnabled and ignore bottomToolbar button presses if
  editingEnabled returns NO.

[r161148] We were iterating through all of the views in the color picker,
  looking for swatches matching the current color. Now we stop looking after
  we find the first one.

[r161296] Before doing something that might cause the software keyboard to
  resize via hiding/showing, clear the _receivedKeyboardWillResize flag we use
  to detect whether the hardware keyboard is being used or not. This avoids
  getting confused about whether to end editing if the software keyboard is
  temporarily shown while in the middle of a renaming session.

[r161299] Adjusted the hack for ignoring spurious keyboard frame change
  notifications on pre- iOS 5.1. Now, if we get a frame change notification
  and the keyboard is supposedly hidden, we use a height of zero rather than
  totally ignoring it.
[r161164] Missing trailing newline.
[r161213] Make the @synthesize refer to the ivar we have for it instead of
dynamically generating some other ivar.
[r161214] Write integral float constants as ints to avoid 64->32 warnings.
[r161313] Mark a color profile related method as OBFinishPortingLater instead
of OBFinishPorting.
[r161133] Added a new OFSDocumentStoreFileItemFinishedDownloadingNotification
notification. Catch this in OUISingleDocumentAppController. Rename
-[OUIDocumentPreviewGenerator fileItemContentsChanged:] to
-fileItemNeedsPreviewUpdate: since it can be called for a couple reasons.
[r161114] Fixed imports of public headers.
[r161181] Only abort() on OFObject inline ref counts being enabled while using
Instruments to track leaks in debug builds. This should allow QA to check for
leaked objects, but they won't have (and don't particularly need) the ref
count log.
[r161412] Updated my commented out clang CC settings. Added one for sdk=iphone* since the latest clang builds work fine on the hardware.
[r161389] <bug:///77585> (document layout animation stutters when creating a new document)

OFSDocumentStore scanItemsWithCompletionHandler: scan-finished-block has a couple of places where the scope is asked for its container URL. This uses -[NSFileManager URLForUbiquityContainerIdentifier:] and I have found out that that can be slow. And, when this is called on each file in the document store, the app can slow down a lot.
Therefore, I added a couple of convenience functions to generate a NSDictionary cache of the store scope containers and is used within these file loops. Note that a couple of the locations are actually assertions and have been ifdef'd appropriately. In addition, the assertion in OFSDocumentStoreFileItem _updateWithMetadataItem: was redundant and expensive so I commented it out for now.
[r161408] Adding a category method for conditionally adding a separator to an NSMenu.
[..r161428] Fixed all warnings noticed by top-of-tree clang (r150196)
[r161433] Renamed the editingEnabled property to editingDisabled. This makes it start out in the correct state for newly created documents.
[r161440] <bug:///77924> (View not scrolling up far enough to see row you're editing)

When in landscape mode, it seems that the order of notifications differs on iOS 5.0.1 such that our _keyboardVisible isn't set early enough.

So, we now listen for UIKeyboardWillShowNotification and set it there. Also, to get the animation started right, we adjust our size in the will-show hook, lest the animation sizing the content be start after the keyboard and the bottom toolbar be hidden temporarily due to lagging behind.
[r161449] <bug:///77920> (Tapping on two file names at the same time blocks interaction with the previews)

It seems that, at least in iOS 5.1, that UIGestureRecognizer queues its actions asynchronously.

This means that two recognizers can accept and queue actions before the first's action has fired.

Rather than asserting that we aren't already in the middle of renaming when a rename is started, actually check and just bail if so.
Retina, iCloud, and ARC updates

Some of the highlights...

General:
  - Now requires Xcode 4.3.
  - Started migrating towards ARC. Not all the way there yet.

OmniUI:
  - Removed unused images
  - Added @2x image variants
  - Added OUIEmptyPaddingInspectorSlice for pushing some slices to the bottom
    of an inspector
  - Added custom keyboard support to OUIInspectorTextWell
  - Replaced OUIAlertView with OUIAlert
  - Added some accessibility support; more to do
  - Finished conflict resolution UI and support
  - Finished iCloud configuration UI and migration of files
  - Finished support for notification of incoming deletes of open documents
  - Automatically close documents when reverting fails (due to the file
    being deleted while the app is in the background)
  - Fixed issues with preview generation while documents are being moved,
    deleted, updated (delay the writer block until we are done).
  - Added support for rendering previews of conflict versions
  - Added support for updating OUIDocument's references to attachments after
    being informed of a move by NSFilePresenter
  - Added Retina-awareness to preview generation
  - Added Retina-awareness to icon selection for import/export pane
  - Added support for badging files that are not on iCloud when iCloud is
    enabled
  - Improved the performance of opening/closing documents
  - Fixed a few edge cases of document renaming cancellation
  - Fixed parent view calcuation for OUIEditableFrame's controls.
  - Added support for locking interaction on the document, but letting
    alerts still have user interaction enabled
  - Don't open conflicted/not downloaded document on launch
  - Added top-level Omni Sync Server item to import/export

OmniFileStore:
  - Added support for migrating documents into/out of the ubiquity scope.
  - Added support for resolving conflicts.
  - Added support for automatically downloading small documents when on Wi-Fi
  - Reduce the number of redundant scan operations
  - Add support for informing the OFSFileStore delegate of move/copy
    operations (used to update preview cache w/o rebuilding them).
  - Properly deal with iCloud asking us to relinquishing to writer.
    This is complicated. Response to changes is buffered until we reacquire
    or processed immediately if we aren't in a writer block.
  - A bunch of other iCloud bug workarounds, and cleanup
  - Add file item support for tracking whether an instance is in iCloud and
    whether a download has been requested (even if it hasn't started).
  - Disable ubiquity support on iOS if the device is not running 5.1 or later

Configurations:
  - Code signing updates
  - Enable GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS and
    CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS
  - Add notes next to a few other new warnings about why they aren't on yet

Scripts:
  - Run Xcode's pngcrush on iOS when copying library resources
  - OmniRunUnitTests handled more configurations
  - Added Scripts/rubylib/xcodeproj.rb, a simple helper for dealing with
    Xcode projects

OmniBase:
  - Added ARC helper macros, OB_STRONG, OB_BRIDGE, and OB_AUTORELEASING
  - Added OB_FOR_IN
  - Added OBASSERT_IF
  - Added some unit tests

OmniFoundation:
  - Turned off GC support, but not all the code is removed.
  - Made the public header ARC safe
  - Updated OFUTI to service more requests out of our local plist instead
    of trusting LaunchServices (which will return crazy info from other apps)
  - Made OFBindingPoint an object instead of a struct, for ARC
  - Made a few other classes ARC compatible
  - Add -[NSProcessInfo isSandboxed]

OmniAppKit:
  - Removed implementations of deprecated methods
  - Declare some used methods as API (moving towards enabling -Wselector)
  - Removed implementation of deprecated drag source method from
    OADragController and the delegate (no longer used).
  - Reeanbled OA_USE_COLOR_MANAGER for now. Still need to find a replacement.
  - Removed duplicate implementation of quarantine extensions
  - Remove NSTableView(OAExtensions) -tableView:draggingSourceOperationMaskForLocal:
    hack. Use the public API.

OmniQuartz
  - Added very basic performance logging for -renderInContext:.
  - Enable -[CALayer(OQExtensions) renderInContextIgnoringCache:] on iOS

TextEditor:
  - Removed the Midsummer.rtf sample for now. This sample app needs to be
    updated to avoid memory warnings/crashes when generating Retina scale
    previews for large documents