Skip navigation
This discussion is archived

AppleWorks drawings to Pages.

15458 Views 66 Replies Latest reply: May 3, 2009 6:07 AM by lbrookins RSS
  • Level 8 Level 8 (41,760 points)
    Currently Being Moderated
    Apr 21, 2009 3:15 AM (in response to Roger Wilmut1)
    (1) I already explain that the extraneous pages are due to the fact that in your original file some objects are greater than a single page so, the script is forced to take care of that.
    It can't decide by itself if the width of the original document is only one page.
    I will continue to search where is stored the info about the number of pages in width and in height is stored in the documents.

    (2) there is no need to bring a document at front to speak to it.
    If you really want to bring one at front, you may use this handler which is OK for Pages and Numbers:


    tell application "Numbers"
    set doc1 to name of document 1
    set doc2 to name of document 2
    my selectDoc("Numbers", doc2)
    tell document doc2
    --
    end tell
    end tell

    on selectDoc(a, n)
    if a = "Pages" then
    set f to 9
    else if a = "Numbers" then
    set f to 10
    else
    error "The application “" & a & "“ is not accepted !"
    end if

    tell application a to activate
    tell application "System Events" to tell application process a to tell menu bar 1 to tell menu bar item f to tell menu 1 to click menu item n
    end selectDoc


    Yvan KOENIG (from FRANCE mardi 21 avril 2009 12:15:09)
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !, Mac OS X (10.4.11)
  • woodsbr3 Level 1 Level 1 (0 points)
    Currently Being Moderated
    Apr 21, 2009 3:59 AM (in response to KOENIG Yvan)
    Hi

    I've fixed it - I had a look at what version of appleworks 6 I had and it was only 6.2.2.. I ran the updater for appleworks to upgrade to 6.2.9 and it all works. Thanks heaps for your help

    Brian
    MacBook, Mac OS X (10.5.6)
  • Level 8 Level 8 (41,760 points)
    Currently Being Moderated
    Apr 21, 2009 10:03 AM (in response to Roger Wilmut1)
    (1) I assume that it's the selectDoc handler which works OK.
    (2) I think that I found a way to get rid of the extraneous blank pages.

    May you check that this script:



    set cheminsource to (choose file with prompt "Choose an AppleWorks Draw document…" of type {"com.apple.appleworks.cwk"}) as text

    set enTexte to read file cheminSourceGR from 27 for 24
    set measures to {}
    repeat with i from 1 to count of enTexte by 2
    copy ((ASCII number of character i of enTexte) * 256) + (ASCII number of character (i + 1) of enTexte) to end of measures
    end repeat

    tell measures
    set isLandscape to (item 3 < item 4)
    set {mG, mH, mD, mB} to {item 6, item 5, item 8, item 7}
    set page_Width to (item 4) - mG - mD
    set page_Height to (item 3) - mH - mB
    end tell -- measures
    set enTexte to read file cheminSourceGR from 1800 for 6
    set measures2 to {}
    repeat with i from 1 to count of enTexte by 2
    copy ((ASCII number of character i of enTexte) * 256) + (ASCII number of character (i + 1) of enTexte) to end of measures2
    end repeat

    if isLandscape then
    set {beg, ww, hh} to {2138, 3, 1}
    else
    set {beg, ww, hh} to {1800, 1, 3}
    end if
    set enTexte to read file cheminSourceGR from beg for 6
    set measures2 to {}
    repeat with i from 1 to count of enTexte by 2
    copy ((ASCII number of character i of enTexte) * 256) + (ASCII number of character (i + 1) of enTexte) to end of measures2
    end repeat
    set doc_width to item ww of measures2
    set doc_height to item hh of measures2
    set nbPagesWidth to doc_width div page_Width
    set nbPagesHeight to doc_height div page_Height

    display alert "isLandscape : " & isLandscape & return & "measures : " & my recolle(measures, ", ") & return & "page_Width : " & page_Width & return & "page_Height : " & page_Height & return & "measures2 : " & my recolle(measures2, ", ") & return & "doc_width : " & doc_width & return & "doc_height : " & doc_height & return & "nbPagesWidth : " & nbPagesWidth & return & "nbPagesHeight : " & nbPagesHeight

    on recolle(l, d)
    local t
    set AppleScript's text item delimiters to d
    set t to l as text
    set AppleScript's text item delimiters to ""
    return t
    end recolle


    returns the correct numbers of pages in width and in height of Draw documents.

    Just run it, it will ask you to select a Draw document and will display some parameters.
    Here, I got correct results but I wish to be sure that it's OK before changing the scripts.

    (3) I'm not sure than I understand well the question about tabs.
    When a Draw document containing text frames with tabs embedded, all the features of these tabs are correctly passed thru my scripts.
    When we use copy paste from AppleWorks to Pages I'm not surprised that some attributes are lost.
    The ruler is not passed during the "normalization" process of the clipboard's contents.
    It would be better to import your document.

    Yvan KOENIG (from FRANCE mardi 21 avril 2009 19:03:50)
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !, Mac OS X (10.4.11)
  • Level 8 Level 8 (41,760 points)
    Currently Being Moderated
    Apr 21, 2009 12:19 PM (in response to Roger Wilmut1)
    I repeat that it's the normal behavior.

    When you copy paste from AW6_DB to AW6_WP you remain in AW6 so the clipboard keeps all the features defined in the application. It's what we call a"private clipboard".
    When you paste in Pages, you leave the "private clipboard". This requires what is called "clipboard normalization". This drop a lot of features retaining only a short subset of features.

    A workaround would be to copy from the DB, paste in a n AW6 WP then import this WP in Pages.

    It's easy to do an it's eaven easy to drive with an AppleScript.
    It's the kind of tip which I use to insert styled text in Numbers cells with AppleScript.

    Yvan KOENIG (from FRANCE mardi 21 avril 2009 21:19:29)
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !, Mac OS X (10.4.11)
  • Level 8 Level 8 (41,760 points)
    Currently Being Moderated
    Apr 21, 2009 1:01 PM (in response to KOENIG Yvan)
    Here is a script which pass converts the AW clipboard into a Pages one retaining every attributes.


    (* copy some styled datas from an AppleWorks 6 document,
    from a database for instance.
    Run the script.
    It will paste in a temporary AW6 WP.
    It saves the document then close it.

    Pages is asked to open this WP.
    The script selects all,
    copy to the clipboard
    close the temporary Pages document.

    Yvan KOENIG (Vallauris, FRANCE)
    21 avril 2009
    *)

    on run

    set WPname to "fromDB2WP.cwk"
    set p2t to path to temporary items as text
    set p2tWP to p2t & WPname
    tell application "System Events"
    if exists file p2tWP then delete file p2tWP
    make new file at end of folder p2t with properties {name:WPname, file type:"CWWP"}
    end tell
    tell application "AppleWorks 6"
    activate
    make new document at front with properties {document kind:text document, name:WPname}
    tell document WPname
    paste
    end tell
    save document WPname in (p2tWP as alias)
    close document WPname
    end tell -- AppleWorks

    tell application "Pages"
    open file p2tWP
    set pName to name of document 1
    tell document pName
    --
    end tell
    my shortcut("Pages", "ac")
    close document pName saving no
    end tell -- Pages
    (* now the original AW clipboard is replaced by a Pages one whith all original attributes *)
    end run

    --=====

    on shortcut(a, t)
    tell application a to activate
    tell application "System Events" to tell application process a
    repeat with i from 1 to count of t
    keystroke ((character i of t) as text) using {command down}
    end repeat
    end tell
    end shortcut

    --=====


    As I wrote, it was really easy top build it

    Yvan KOENIG (from FRANCE mardi 21 avril 2009 22:00:34)
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !, Mac OS X (10.4.11)
  • Level 8 Level 8 (41,760 points)
    Currently Being Moderated
    Apr 22, 2009 2:20 AM (in response to Roger Wilmut1)
    If you have to do the trick often, it would be useful to build a merge document which will grab the infos from the DB to a word processor.
    Given that, the values will benefit of the ruler installed in the merged document.

    It's an old workaround but it may be useful here.

    Yvan KOENIG (from FRANCE mercredi 22 avril 2009 11:20:00)
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !, Mac OS X (10.4.11)
  • Level 8 Level 8 (41,760 points)
    Currently Being Moderated
    Apr 22, 2009 2:34 AM (in response to Roger Wilmut1)
    Thanks for the feedback.

    As You aked me, I destroyed the sample file which you sent me.
    Given your comment, I scrapped my head and realized that maybe it was available in Mails archives. Happily it was.

    So I was able to look in its internals.
    I discovered that old documents created with old AppleWorks 5 have a structure different than those created directly in AppleWorks 6.
    This will make the task more complex but I am on the track

    OK for the request about passing the result in the clipboard.

    Yvan KOENIG (from FRANCE mercredi 22 avril 2009 11:33:54)
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !, Mac OS X (10.4.11)

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.