diff --git a/.github/workflows/build-accdb.yml b/.github/workflows/build-accdb.yml index e1e8440..27fe0c8 100644 --- a/.github/workflows/build-accdb.yml +++ b/.github/workflows/build-accdb.yml @@ -24,7 +24,7 @@ jobs: steps: - name: "Checkout code for release tag" - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: ref: ${{ github.event.release.tag_name }} @@ -58,14 +58,14 @@ jobs: timeout-minutes: 10 - name: "Upload Build Artifact" - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 id: "upload" with: name: "Install files" path: "./bin/*" if-no-files-found: warn - name: "Attestation" - uses: actions/attest-build-provenance@v2 + uses: actions/attest-build-provenance@v4 with: subject-name: "Install files" subject-digest: sha256:${{ steps.upload.outputs.artifact-digest }} diff --git a/.github/workflows/build-release-zip-file.yml b/.github/workflows/build-release-zip-file.yml index b4f0b20..07f1c4b 100644 --- a/.github/workflows/build-release-zip-file.yml +++ b/.github/workflows/build-release-zip-file.yml @@ -15,7 +15,7 @@ jobs: steps: - name: "Checkout code for release tag" - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: ref: ${{ github.event.release.tag_name }} @@ -26,6 +26,7 @@ jobs: source-dir: "source" target-dir: "bin" file-name: "ACLibDeclarationDict.accda" + app-config: "deployment/AddIn-Config.json" run-accunit-tests: true timeout-minutes: 10 @@ -46,7 +47,7 @@ jobs: echo "ZIP_NAME=$zipName" | Out-File -FilePath $env:GITHUB_ENV -Append - name: "Upload ZIP to GitHub Release" - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v3 with: files: ${{ env.ZIP_NAME }} env: @@ -63,7 +64,7 @@ jobs: echo "digest=$digest" >> $env:GITHUB_OUTPUT - name: "Attestation" - uses: actions/attest-build-provenance@v2 + uses: actions/attest-build-provenance@v4 id: attestation with: subject-name: "${{ env.ZIP_NAME }}" diff --git a/.gitignore b/.gitignore index 1c0e85c..a747733 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# gitattributes template for Microsoft Access database source files +# gitattributes template for Microsoft Access database source files # Website: https://github.com/joyfullservice/msaccess-vcs-addin # @@ -13,14 +13,22 @@ # The local VCS index file is paired with the binary database file # and should not be comitted to version control. -vcs-index.json +vcs-index.* # Ignore any dotenv files (used for external database connections) *.env +logs/ +test-results/ +.env.* +!.env*.example # Ignore log files generated by the VCS Add-in # Comment out the following line if you wish to include log files in git. *.log -#other files +# others +*.dll *.zip + +# don't commit dict files in this repository +*.accd[ab].DeclarationDict.txt diff --git a/Example_APIusage.accdb.src/modules/_LoadAddIn.bas b/Example_APIusage.accdb.src/modules/_LoadAddIn.bas index 21fe605..cbd0075 100644 --- a/Example_APIusage.accdb.src/modules/_LoadAddIn.bas +++ b/Example_APIusage.accdb.src/modules/_LoadAddIn.bas @@ -4,13 +4,15 @@ Option Explicit Public Sub LoadAddIn() -'API: RunVcsCheck(Optional ByVal OpenDialogToFixLettercase As Boolean = False) +'API: Public Function RunVcsCheck(Optional ByVal OpenDialogToFixLettercase As Boolean = False, _ +' Optional ByVal DeclDictFilePath As String = vbNullString, _ +' Optional ByVal IncludeUsedMembers As Boolean = False) As Variant Dim AddInCallPath As String AddInCallPath = CurrentProject.Path & "\ACLibDeclarationDict.RunVcsCheck" Dim Result As Variant - Result = Application.Run(AddInCallPath, True) + Result = Application.Run(AddInCallPath, True, vbNullString, True) If Result = True Then Debug.Print "No problems with letter case" Else diff --git a/Example_APIusage.accdb.src/vcs-options.json b/Example_APIusage.accdb.src/vcs-options.json index ead0f48..0d34347 100644 --- a/Example_APIusage.accdb.src/vcs-options.json +++ b/Example_APIusage.accdb.src/vcs-options.json @@ -1,6 +1,6 @@ { "Info": { - "AddinVersion": "4.1.2", + "AddinVersion": "4.1.3", "AccessVersion": "16.0 64-bit" }, "Options": { diff --git a/README.md b/README.md index 56bfa56..2ad17a1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # ACLib Declaration Dictionary + This Add-In lists all VBA declarations (variables, function names, constants, etc.) and ensures consistent letter case. The idea was born from a discussion ([msaccess-vcs-add-in: issue 599](https://github.com/joyfullservice/msaccess-vcs-addin/issues/599)) about the behavior of the VBA editor, which adapts each existing declaration to the last written capitalization of the same word. This leads to many unnecessary changes in commits when using a version control system. @@ -7,16 +8,29 @@ The idea was born from a discussion ([msaccess-vcs-add-in: issue 599](https://gi # ACLibDeclarationDictionaryCore + Core components: https://github.com/AccessCodeLib/ACLibDeclarationDictionaryCore +## Branches + +| Branch | Purpose | +|---|---| +| `main` | Release line of this add-in | +| `add-in-dev` | Development of the add-in | +| `core` | Mirror of the `main` branch of ACLibDeclarationDictionaryCore | + +Core changes are developed in the Core repository and taken over 1:1 into this repository; add-in specific code is added on top. +Core updates are merged, not rebased: `core` is updated from Core `main`, then merged into `add-in-dev` (preferably via a `feature/core-` branch and a pull request). + ## API -### RunVcsCheck([OpenDialogToFixLettercase], [DeclDictFilePath]) As Variant +### RunVcsCheck([OpenDialogToFixLettercase], [DeclDictFilePath], [IncludeUsedMembers]) As Variant Compare lettercase from CurrentVbProject with saved file dictionary items #### Parameters - OpenDialogToFixLettercase - (Boolean) - Open dialog to fix lettercase - DeclDictFilePath - (String) - use alternative dictionary file path +- IncludeUsedMembers - (Boolean) - also add used members to the dictionary (default: False) #### Returns - Boolean (True) ... if DiffCount = 0 @@ -35,4 +49,4 @@ End If ``` ### RunVcsCheckDialog() -Equal to RunVcsCheck(True) +Equal to RunVcsCheck(True, , True) diff --git a/Tests/ACLibDeclarationDict/DeclarationDictTests.cls b/Tests/ACLibDeclarationDict/DeclarationDictTests.cls index 251812f..35d1deb 100644 --- a/Tests/ACLibDeclarationDict/DeclarationDictTests.cls +++ b/Tests/ACLibDeclarationDict/DeclarationDictTests.cls @@ -56,7 +56,10 @@ Public Sub ImportCode_InsertCodeLine_CheckKeys(ByVal Code As String, ByVal Expec Dim Actual As String - m_DeclDict.ImportCode Code + With New CodemoduleDeclarationReader + .ImportCode Code, m_DeclDict + End With + 'm_DeclDict.ImportCode Code Actual = Join(m_DeclDict.WordsDict.Keys, "|") Assert.That Actual, Iz.EqualTo(Expected) @@ -73,7 +76,9 @@ Public Sub ImportCode_Issue4_MultiDimArrayDeclaration(ByVal Code As String, ByVa Dim Actual As String - m_DeclDict.ImportCode Code + With New CodemoduleDeclarationReader + .ImportCode Code, m_DeclDict + End With Actual = Join(m_DeclDict.WordsDict.Keys, "|") Assert.That Actual, Iz.EqualTo(Expected) @@ -89,7 +94,9 @@ Public Sub ImportCode_InsertCodeLines_CheckKeys(ByVal Code As String, ByVal Expe Dim Actual As String - m_DeclDict.ImportCode Code + With New CodemoduleDeclarationReader + .ImportCode Code, m_DeclDict + End With Actual = Join(m_DeclDict.WordsDict.Keys, "|") Assert.That Actual, Iz.EqualTo(Expected) @@ -101,7 +108,9 @@ Public Sub ImportCode_Issue3_RemovingCommentCorruptsLineEndings(ByVal Code As St Dim Actual As String - m_DeclDict.ImportCode Code + With New CodemoduleDeclarationReader + .ImportCode Code, m_DeclDict + End With Actual = Join(m_DeclDict.WordsDict.Keys, "|") Assert.That Actual, Iz.EqualTo(Expected) @@ -114,7 +123,9 @@ Public Sub ImportCode_Pullrequest8_LineLabel(ByVal Code As String, ByVal Expecte Dim Actual As String - m_DeclDict.ImportCode Code + With New CodemoduleDeclarationReader + .ImportCode Code, m_DeclDict + End With Actual = Join(m_DeclDict.WordsDict.Keys, "|") Assert.That Actual, Iz.EqualTo(Expected) @@ -135,7 +146,9 @@ Public Sub ImportCode_API_CheckKeys(ByVal Code As String, ByVal Expected As Stri ' RegEx.Pattern = "(?:Declare)\s(Function|Sub)\s([^ ]*)[^(]*\(" ' Actual = RegEx.Replace(Code, "$1 $2(") - m_DeclDict.ImportCode Code + With New CodemoduleDeclarationReader + .ImportCode Code, m_DeclDict + End With Actual = Join(m_DeclDict.WordsDict.Keys, "|") Assert.That Actual, Iz.EqualTo(Expected) @@ -156,7 +169,9 @@ Public Sub ImportCode_EnumCode_CheckKeys() Const Expected As String = "xyz|en1|en2|x|y" - m_DeclDict.ImportCode Code + With New CodemoduleDeclarationReader + .ImportCode Code, m_DeclDict + End With Actual = Join(m_DeclDict.WordsDict.Keys, "|") Assert.That Actual, Iz.EqualTo(Expected) @@ -177,7 +192,9 @@ Public Sub ImportCode_TypeCode_CheckKeys() Const Expected As String = "xyz|F1|F2|x|y" - m_DeclDict.ImportCode Code + With New CodemoduleDeclarationReader + .ImportCode Code, m_DeclDict + End With Actual = Join(m_DeclDict.WordsDict.Keys, "|") Assert.That Actual, Iz.EqualTo(Expected) @@ -211,7 +228,9 @@ Public Sub ImportClassCodeModule_CheckKeysExists() "TestPullrequest8_LineLabels", "ExitHere", "ErrHandler") - m_DeclDict.ImportVBComponent CurrentVbProject.VBComponents("DeclarationDictTestCodemodule") + With New CodemoduleDeclarationReader + .ImportVBComponent CurrentVbProject.VBComponents("DeclarationDictTestCodemodule"), m_DeclDict + End With Set ActualDict = m_DeclDict.WordsDict @@ -224,3 +243,16 @@ Public Sub ImportClassCodeModule_CheckKeysExists() End Sub +Public Sub ToString_AddWords_OutputVariations() + + m_DeclDict.AddWord "Test" + m_DeclDict.AddWord "test" + m_DeclDict.AddWord "xyz" + m_DeclDict.AddWord "xyz" + + Dim Actual As String + Actual = m_DeclDict.ToString(False) + + Assert.That Actual, Iz.EqualTo("Test:Test|test") + +End Sub diff --git a/deployment/AddIn-Config.json b/deployment/AddIn-Config.json new file mode 100644 index 0000000..ad4a61f --- /dev/null +++ b/deployment/AddIn-Config.json @@ -0,0 +1,9 @@ +{ + "DatabaseProperties": [ + { + "Name": "StartUpForm", + "Type": 10, + "Value": "InstallAddInForm" + } + ] +} diff --git a/source/AGENTS.md b/source/AGENTS.md new file mode 100644 index 0000000..f3d3495 --- /dev/null +++ b/source/AGENTS.md @@ -0,0 +1,99 @@ +# AGENTS.md - Working With Exported Microsoft Access Source Files + +This folder is a Microsoft Access database exported to text files by the MSAccess +VCS add-in. Editing these files is how you change the database, but edits only +take effect when the add-in imports them back in Access. You cannot run or test +this code directly, and the add-in is required to build a working database from it. + +This file and everything under `vcs-agent-docs/` are generated by the add-in and +**rewritten on every export**. Keep your own project notes elsewhere. + +## Non-negotiable rules + +1. **Do not change file encoding.** Source files are UTF-8, and most are UTF-8 + *with BOM* (bytes `EF BB BF`). Re-saving without the BOM makes import fail or + silently corrupt the object. +2. **Do not change line endings.** Access `LoadFromText` requires CRLF (`\r\n`). +3. **Do not edit** `vcs-index.idx` (binary change index), `.frx` files (binary OLE + data), or `.thmx` files (ZIP archives — edit the extracted contents instead). +4. **Do not rename a file** without changing the object name stored inside it. + File names must match object names exactly. +5. **Do not alter VBA scaffolding:** `Attribute VB_Name` lines, the + `VERSION`/`BEGIN`/`END` block at the top of a `.cls`, or module-level + `Attribute VB_*` lines. The code below them is yours to edit. + +## Which file do I edit? + +| To change | Edit | Read first | +|---|---|---| +| VBA in a standard module | `modules/.bas` | `vcs-agent-docs/vba-modules.md` | +| VBA in a class module | `modules/.cls` | `vcs-agent-docs/vba-modules.md` | +| Form or report code-behind | `forms/.cls`, `reports/.cls` | `vcs-agent-docs/vba-modules.md` | +| Form or report layout | `forms/.form`, `reports/.report` | `vcs-agent-docs/forms-reports.md` | +| Conditional formatting rules | the form's or report's companion `.json` | `vcs-agent-docs/forms-reports.md` | +| Query logic | `queries/.sql` — the sole source of truth for SQL | `vcs-agent-docs/queries.md` | +| Query properties or design layout | `queries/.json` | `vcs-agent-docs/queries.md` | +| A macro | `macros/.macro` | — | +| A table definition | `tbldefs/.xml` and `.json` | — | +| A connection string | `.env` at this folder's root (gitignored) | `vcs-agent-docs/troubleshooting.md` | +| Tests | a test module under `modules/` | `vcs-agent-docs/testing.md` | + +Export format 5.0.0 renamed several object types from the overloaded `.bas` +extension: forms to `.form`, reports to `.report`, macros to `.macro`, and queries +to `.sql` plus `.json`. Older projects still use `.bas` for these, so check which +extensions are actually present. Import accepts both. + +## File placement follows the `@Folder` annotation + +The add-in reads Rubberduck-style `'@Folder("Category")` annotations and exports +components into matching subdirectories, with dots as path separators: +`'@Folder("Components.ADP")` lands in `modules/Components/ADP/`. Components with no +annotation stay at the root of `modules/`, `forms/`, or `reports/`. Import scans +subdirectories recursively. + +**The annotation decides where the file belongs on disk, not the folder you happen +to be editing in.** This is the most common way agents corrupt a project: + +- For modules, the annotation is in the `.bas` or `.cls` itself. For forms and + reports it lives in the `.cls` code-behind only — not in `.form`/`.report`, + `.json`, or `.svg`. +- Before creating or moving a component, search the **entire** `modules/`, `forms/`, + or `reports/` tree for an existing file with the same base name (for modules, + match on `Attribute VB_Name`). Edit that file in place rather than creating a + second copy elsewhere. +- If two copies exist, such as `modules/modFoo.bas` and `modules/Tests/modFoo.bas`, + build imports **both** and the last one silently wins. No error is shown. +- Build removes a misplaced duplicate automatically when exactly one copy sits in + its annotation-derived folder. Ambiguous cases are left alone with a warning. + Removing a duplicate form or report deletes its whole source group together + (`.form`/`.report` plus `.cls`, `.json`, and `.svg`). + +To relocate a component, change its `'@Folder` annotation and let the next export +move the file. + +## Where the details live + +Each of these is short. Read the matching one before making that kind of change. + +| File | Read it before | +|---|---| +| `vcs-agent-docs/vba-modules.md` | Editing any `.bas` or `.cls`, or adding a member attribute | +| `vcs-agent-docs/forms-reports.md` | Editing a `.form` or `.report` layout, or conditional formatting | +| `vcs-agent-docs/queries.md` | Editing anything in `queries/` | +| `vcs-agent-docs/testing.md` | Writing, running, or filtering tests | +| `vcs-agent-docs/troubleshooting.md` | An import, build, or compile failed, or you need the log files | + +## How changes get back into Access + +Ask the user to run a **merge build** from the add-in ribbon, which imports changed +source files into the existing database. A **full build** creates a new database +from source instead, and **export** goes the other way, writing database objects +out to these files. When a source file and its database object have both changed, +the add-in detects the conflict and prompts the user to choose which version wins. + +## More information + +- [MSAccess VCS Add-in](https://github.com/joyfullservice/msaccess-vcs-addin) +- [Wiki: Export-Import File Types](https://github.com/joyfullservice/msaccess-vcs-addin/wiki/Export-Import-File-Types) +- [Wiki: Supported Objects](https://github.com/joyfullservice/msaccess-vcs-addin/wiki/Supported-Objects) +- [Wiki: Options](https://github.com/joyfullservice/msaccess-vcs-addin/wiki/Options) diff --git a/source/dbs-properties.json b/source/dbs-properties.json index dbe610e..c52f41e 100644 --- a/source/dbs-properties.json +++ b/source/dbs-properties.json @@ -101,7 +101,7 @@ "Type": 4 }, "NavPane Width": { - "Value": 678, + "Value": 540, "Type": 4 }, "Never Cache": { @@ -156,10 +156,6 @@ "Value": true, "Type": 1 }, - "StartUpForm": { - "Value": "InstallAddInForm", - "Type": 10 - }, "StartUpShowDBWindow": { "Value": true, "Type": 1 @@ -209,7 +205,7 @@ "Type": 2 }, "Version": { - "Value": "14.0", + "Value": "12.0", "Type": 12 }, "WebDesignMode": { diff --git a/source/documents.json b/source/documents.json index f7097aa..758ccf9 100644 --- a/source/documents.json +++ b/source/documents.json @@ -6,10 +6,22 @@ "Items": { "Databases": { "SummaryInfo": { - "Author": "Josef Pötzl", - "Comments": "* List of declarations\r\n* Save to / load from table or file\r\n* Compare and repair letter case", - "Company": "access-codelib.net", - "Title": "ACLib Declaration Dictionary" + "Author": { + "Type": 10, + "Value": "Josef Pötzl" + }, + "Comments": { + "Type": 10, + "Value": "* List of declarations\r\n* Save to / load from table or file\r\n* Compare and repair letter case" + }, + "Company": { + "Type": 10, + "Value": "access-codelib.net" + }, + "Title": { + "Type": 10, + "Value": "ACLib Declaration Dictionary" + } } } } diff --git a/source/forms/DeclarationDictApiDialog.cls b/source/forms/DeclarationDictApiDialog.cls index b58c405..3b85687 100644 --- a/source/forms/DeclarationDictApiDialog.cls +++ b/source/forms/DeclarationDictApiDialog.cls @@ -205,7 +205,7 @@ Private Sub RefreshDiffData() Else With Me.lbDictData Set .Recordset = m_WordListRecordset - .Value = Me.lbDictData.Column(0, 0) + .Value = .Column(0, Abs(.ColumnHeads)) End With FillWordVariationsList End If diff --git a/source/forms/DeclarationDictApiDialog.bas b/source/forms/DeclarationDictApiDialog.form similarity index 68% rename from source/forms/DeclarationDictApiDialog.bas rename to source/forms/DeclarationDictApiDialog.form index 05feb0c..1db0cf3 100644 --- a/source/forms/DeclarationDictApiDialog.bas +++ b/source/forms/DeclarationDictApiDialog.form @@ -13,13 +13,13 @@ Begin Form DatasheetGridlinesBehavior =3 Cycle =1 GridY =10 - Width =10148 + Width =10140 DatasheetFontHeight =11 ItemSuffix =88 - Left =5811 - Top =3026 - Right =24429 - Bottom =14117 + Left =1000 + Top =1000 + Right =50000 + Bottom =50000 RecSrcDt = Begin 0x1b36415d9252e640 End @@ -142,7 +142,7 @@ Begin Form GridlineShade =65.0 End Begin Section - Height =4649 + Height =4620 Name ="Detail" AlternateBackThemeColorIndex =1 AlternateBackShade =95.0 @@ -168,19 +168,15 @@ Begin Form AllowValueListEdits =0 InheritValueList =0 - LayoutCachedLeft =60 - LayoutCachedTop =57 - LayoutCachedWidth =5476 - LayoutCachedHeight =4593 End Begin ListBox RowSourceTypeInt =1 OverlapFlags =85 IMESentenceMode =3 - Left =5674 - Top =1397 + Left =5640 + Top =1380 Width =4380 - Height =1354 + Height =1320 TabIndex =3 ForeColor =0 Name ="lbVariations" @@ -196,10 +192,6 @@ Begin Form AllowValueListEdits =0 InheritValueList =0 - LayoutCachedLeft =5674 - LayoutCachedTop =1397 - LayoutCachedWidth =10054 - LayoutCachedHeight =2751 RowStart =4 RowEnd =4 ColumnEnd =1 @@ -214,36 +206,20 @@ Begin Form OverlapFlags =85 TextAlign =1 IMESentenceMode =3 - Left =5674 + Left =5640 Top =60 Width =4380 - Height =317 + Height =300 FontWeight =700 TabIndex =1 Name ="txtWord" ControlSource ="=[lbDictData]" Format ="@;;\"(select item)\"" - ConditionalFormat = Begin - 0x0100000086000000010000000100000000000000000000001200000001000000 , - 0xbfbfbf00ffffff00000000000000000000000000000000000000000000000000 , - 0x0000000000000000000000000000000000000000000000000000000000000000 , - 0x5b0074007800740057006f00720064005d0020004900730020004e0075006c00 , - 0x6c0000000000 - End GroupTable =1 HorizontalAnchor =1 - LayoutCachedLeft =5674 - LayoutCachedTop =60 - LayoutCachedWidth =10054 - LayoutCachedHeight =377 ColumnEnd =1 LayoutGroup =1 - ConditionalFormat14 = Begin - 0x010001000000010000000000000001000000bfbfbf00ffffff00110000005b00 , - 0x74007800740057006f00720064005d0020004900730020004e0075006c006c00 , - 0x000000000000000000000000000000000000000000 - End GroupTable =1 End Begin CommandButton @@ -271,22 +247,13 @@ Begin Form OverlapFlags =85 TextAlign =1 IMESentenceMode =3 - Left =5674 - Top =737 + Left =5640 + Top =720 Width =4380 Height =300 TabIndex =2 Name ="txtCurrentLetterCase" Format ="@;;---" - ConditionalFormat = Begin - 0x01000000dc000000020000000100000000000000000000001200000001000000 , - 0xbfbfbf00ffffff000100000000000000130000003d00000001010000ba141900 , - 0xffffff0000000000000000000000000000000000000000000000000000000000 , - 0x5b0074007800740057006f00720064005d0020004900730020004e0075006c00 , - 0x6c000000000053007400720043006f006d00700028005b007400780074005700 , - 0x6f00720064005d002c005b00740078007400430075007200720065006e007400 , - 0x560061006c00750065005d002c00300029003c003e00300000000000 - End GroupTable =1 TopPadding =0 GridlineWidthLeft =0 @@ -295,30 +262,17 @@ Begin Form GridlineWidthBottom =0 HorizontalAnchor =1 - LayoutCachedLeft =5674 - LayoutCachedTop =737 - LayoutCachedWidth =10054 - LayoutCachedHeight =1037 RowStart =2 RowEnd =2 ColumnEnd =1 LayoutGroup =1 - ConditionalFormat14 = Begin - 0x010002000000010000000000000001000000bfbfbf00ffffff00110000005b00 , - 0x74007800740057006f00720064005d0020004900730020004e0075006c006c00 , - 0x0000000000000000000000000000000000000000000100000000000000010100 , - 0x00ba141900ffffff002900000053007400720043006f006d00700028005b0074 , - 0x007800740057006f00720064005d002c005b0074007800740043007500720072 , - 0x0065006e007400560061006c00750065005d002c00300029003c003e00300000 , - 0x0000000000000000000000000000000000000000 - End GroupTable =1 End Begin Label OverlapFlags =85 TextAlign =1 - Left =5674 - Top =437 + Left =5640 + Top =420 Width =4380 Height =300 Name ="Label19" @@ -326,10 +280,6 @@ Begin Form GroupTable =1 BottomPadding =0 HorizontalAnchor =1 - LayoutCachedLeft =5674 - LayoutCachedTop =437 - LayoutCachedWidth =10054 - LayoutCachedHeight =737 RowStart =1 RowEnd =1 ColumnEnd =1 @@ -339,8 +289,8 @@ Begin Form Begin Label OverlapFlags =85 TextAlign =1 - Left =5674 - Top =1097 + Left =5640 + Top =1080 Width =4380 Height =300 Name ="Label20" @@ -348,10 +298,6 @@ Begin Form GroupTable =1 BottomPadding =0 HorizontalAnchor =1 - LayoutCachedLeft =5674 - LayoutCachedTop =1097 - LayoutCachedWidth =10054 - LayoutCachedHeight =1397 RowStart =3 RowEnd =3 ColumnEnd =1 @@ -365,44 +311,28 @@ Begin Form OverlapFlags =85 TextAlign =1 IMESentenceMode =3 - Left =5674 - Top =3111 - Width =3403 - Height =343 + Left =5640 + Top =3120 + Width =3420 + Height =360 TabIndex =4 Name ="txtSelectedLetterCase" ControlSource ="=[lbVariations]" Format ="@;;---" - ConditionalFormat = Begin - 0x0100000086000000010000000100000000000000000000001200000001000000 , - 0xbfbfbf00ffffff00000000000000000000000000000000000000000000000000 , - 0x0000000000000000000000000000000000000000000000000000000000000000 , - 0x5b0074007800740057006f00720064005d0020004900730020004e0075006c00 , - 0x6c0000000000 - End GroupTable =1 TopPadding =0 HorizontalAnchor =1 - LayoutCachedLeft =5674 - LayoutCachedTop =3111 - LayoutCachedWidth =9077 - LayoutCachedHeight =3454 RowStart =6 RowEnd =6 LayoutGroup =1 - ConditionalFormat14 = Begin - 0x010001000000010000000000000001000000bfbfbf00ffffff00110000005b00 , - 0x74007800740057006f00720064005d0020004900730020004e0075006c006c00 , - 0x000000000000000000000000000000000000000000 - End GroupTable =1 End Begin Label OverlapFlags =85 TextAlign =1 - Left =5674 - Top =2777 + Left =5640 + Top =2760 Width =4380 Height =300 Name ="Label45" @@ -410,10 +340,6 @@ Begin Form GroupTable =1 TopPadding =0 HorizontalAnchor =1 - LayoutCachedLeft =5674 - LayoutCachedTop =2777 - LayoutCachedWidth =10054 - LayoutCachedHeight =3077 RowStart =5 RowEnd =5 ColumnEnd =1 @@ -423,10 +349,10 @@ Begin Form Begin CommandButton Enabled = NotDefault OverlapFlags =85 - Left =9137 - Top =3111 - Width =917 - Height =343 + Left =9120 + Top =3120 + Width =900 + Height =360 TabIndex =5 Name ="cmdChangeLetterCase" Caption ="Commit" @@ -435,10 +361,6 @@ Begin Form TopPadding =0 HorizontalAnchor =1 - LayoutCachedLeft =9137 - LayoutCachedTop =3111 - LayoutCachedWidth =10054 - LayoutCachedHeight =3454 RowStart =6 RowEnd =6 ColumnStart =1 @@ -464,10 +386,6 @@ Begin Form FontSize =8 Name ="lblVersionInfo" HorizontalAnchor =2 - LayoutCachedLeft =5555 - LayoutCachedTop =4370 - LayoutCachedWidth =10105 - LayoutCachedHeight =4593 End End End diff --git a/source/forms/DeclarationDictApiDialog.json b/source/forms/DeclarationDictApiDialog.json new file mode 100644 index 0000000..7c630d8 --- /dev/null +++ b/source/forms/DeclarationDictApiDialog.json @@ -0,0 +1,62 @@ +{ + "Info": { + "Class": "clsDbForm", + "Description": "DeclarationDictApiDialog Conditional Formatting" + }, + "Items": { + "ConditionalFormatting": { + "txtWord": { + "Rules": [ + { + "Type": "Expression", + "Enabled": true, + "FontBold": false, + "FontItalic": false, + "FontUnderline": false, + "ForeColor": "RGB(191,191,191)", + "BackColor": "RGB(255,255,255)", + "Expression1": "[txtWord] Is Null" + } + ] + }, + "txtCurrentLetterCase": { + "Rules": [ + { + "Type": "Expression", + "Enabled": true, + "FontBold": false, + "FontItalic": false, + "FontUnderline": false, + "ForeColor": "RGB(191,191,191)", + "BackColor": "RGB(255,255,255)", + "Expression1": "[txtWord] Is Null" + }, + { + "Type": "Expression", + "Enabled": true, + "FontBold": true, + "FontItalic": false, + "FontUnderline": false, + "ForeColor": "RGB(186,20,25)", + "BackColor": "RGB(255,255,255)", + "Expression1": "StrComp([txtWord],[txtCurrentValue],0)<>0" + } + ] + }, + "txtSelectedLetterCase": { + "Rules": [ + { + "Type": "Expression", + "Enabled": true, + "FontBold": false, + "FontItalic": false, + "FontUnderline": false, + "ForeColor": "RGB(191,191,191)", + "BackColor": "RGB(255,255,255)", + "Expression1": "[txtWord] Is Null" + } + ] + } + } + } +} diff --git a/source/forms/DeclarationDictForm.cls b/source/forms/DeclarationDictForm.cls index ae68f65..164aad1 100644 --- a/source/forms/DeclarationDictForm.cls +++ b/source/forms/DeclarationDictForm.cls @@ -103,12 +103,18 @@ Private Sub cmdChangeLetterCase_Click() End Sub Private Sub cmdUpdateDict_Click() - ActiveDeclarationDict.ImportVBProject CurrentVbProject + + With New CodemoduleDeclarationReader + .ImportVBProject CurrentVbProject, ActiveDeclarationDict, True + End With + If Not (m_InsertRecordset Is Nothing) Then m_InsertRecordset.Close Set m_InsertRecordset = Nothing End If + RequeryDictData + End Sub Private Sub lbDictData_AfterUpdate() diff --git a/source/forms/DeclarationDictForm.bas b/source/forms/DeclarationDictForm.form similarity index 72% rename from source/forms/DeclarationDictForm.bas rename to source/forms/DeclarationDictForm.form index a5e7dfc..a2beefc 100644 --- a/source/forms/DeclarationDictForm.bas +++ b/source/forms/DeclarationDictForm.form @@ -13,13 +13,13 @@ Begin Form DatasheetGridlinesBehavior =3 Cycle =1 GridY =10 - Width =10148 + Width =10140 DatasheetFontHeight =11 ItemSuffix =81 - Left =7620 - Top =3045 - Right =20775 - Bottom =14775 + Left =1000 + Top =1000 + Right =50000 + Bottom =50000 OnUnload ="[Event Procedure]" RecSrcDt = Begin 0x1b36415d9252e640 @@ -144,7 +144,7 @@ Begin Form GridlineShade =65.0 End Begin Section - Height =6236 + Height =6240 Name ="Detail" AlternateBackThemeColorIndex =1 AlternateBackShade =95.0 @@ -169,10 +169,6 @@ Begin Form AllowValueListEdits =0 InheritValueList =0 - LayoutCachedLeft =60 - LayoutCachedTop =789 - LayoutCachedWidth =5476 - LayoutCachedHeight =5331 End Begin OptionGroup SpecialEffect =0 @@ -187,9 +183,6 @@ Begin Form DefaultValue ="1" HorizontalAnchor =2 - LayoutCachedLeft =57 - LayoutCachedWidth =5160 - LayoutCachedHeight =456 Begin Begin Label BackStyle =1 @@ -200,10 +193,6 @@ Begin Form Height =345 Name ="labFilterSelection" Caption ="Show" - LayoutCachedLeft =120 - LayoutCachedTop =60 - LayoutCachedWidth =960 - LayoutCachedHeight =405 End Begin OptionButton OverlapFlags =87 @@ -212,10 +201,6 @@ Begin Form OptionValue =1 Name ="Option4" - LayoutCachedLeft =1020 - LayoutCachedTop =80 - LayoutCachedWidth =1280 - LayoutCachedHeight =320 Begin Begin Label OverlapFlags =247 @@ -225,10 +210,6 @@ Begin Form Height =315 Name ="Label5" Caption ="Differences " - LayoutCachedLeft =1250 - LayoutCachedTop =50 - LayoutCachedWidth =2450 - LayoutCachedHeight =365 End End End @@ -240,10 +221,6 @@ Begin Form OptionValue =0 Name ="Option6" - LayoutCachedLeft =2608 - LayoutCachedTop =80 - LayoutCachedWidth =2868 - LayoutCachedHeight =320 Begin Begin Label OverlapFlags =247 @@ -253,10 +230,6 @@ Begin Form Height =315 Name ="Label7" Caption ="Full list" - LayoutCachedLeft =2838 - LayoutCachedTop =50 - LayoutCachedWidth =3663 - LayoutCachedHeight =365 End End End @@ -266,10 +239,10 @@ Begin Form RowSourceTypeInt =1 OverlapFlags =85 IMESentenceMode =3 - Left =5674 - Top =1911 + Left =5700 + Top =1920 Width =4380 - Height =1354 + Height =1380 TabIndex =8 ForeColor =0 Name ="lbVariations" @@ -285,10 +258,6 @@ Begin Form AllowValueListEdits =0 InheritValueList =0 - LayoutCachedLeft =5674 - LayoutCachedTop =1911 - LayoutCachedWidth =10054 - LayoutCachedHeight =3265 RowStart =4 RowEnd =4 ColumnEnd =1 @@ -302,36 +271,20 @@ Begin Form OverlapFlags =85 TextAlign =1 IMESentenceMode =3 - Left =5674 - Top =574 + Left =5700 + Top =600 Width =4380 - Height =317 + Height =300 FontWeight =700 TabIndex =6 Name ="txtWord" ControlSource ="=[lbDictData]" Format ="@;;\"(select item)\"" - ConditionalFormat = Begin - 0x0100000086000000010000000100000000000000000000001200000001000000 , - 0xbfbfbf00ffffff00000000000000000000000000000000000000000000000000 , - 0x0000000000000000000000000000000000000000000000000000000000000000 , - 0x5b0074007800740057006f00720064005d0020004900730020004e0075006c00 , - 0x6c0000000000 - End GroupTable =1 HorizontalAnchor =1 - LayoutCachedLeft =5674 - LayoutCachedTop =574 - LayoutCachedWidth =10054 - LayoutCachedHeight =891 ColumnEnd =1 LayoutGroup =1 - ConditionalFormat14 = Begin - 0x010001000000010000000000000001000000bfbfbf00ffffff00110000005b00 , - 0x74007800740057006f00720064005d0020004900730020004e0075006c006c00 , - 0x000000000000000000000000000000000000000000 - End GroupTable =1 End Begin CommandButton @@ -344,10 +297,6 @@ Begin Form Caption ="update data" OnClick ="[Event Procedure]" - LayoutCachedLeft =5494 - LayoutCachedTop =60 - LayoutCachedWidth =7195 - LayoutCachedHeight =457 ForeThemeColorIndex =0 GridlineThemeColorIndex =1 BackThemeColorIndex =4 @@ -375,10 +324,6 @@ Begin Form Name ="txtDictInfo" HorizontalAnchor =2 - LayoutCachedLeft =3741 - LayoutCachedTop =56 - LayoutCachedWidth =4989 - LayoutCachedHeight =356 End Begin CommandButton Transparent = NotDefault @@ -409,10 +354,6 @@ Begin Form "3. [update data]\015\012 4. show differences " HorizontalAnchor =1 VerticalAnchor =1 - LayoutCachedLeft =5669 - LayoutCachedTop =4081 - LayoutCachedWidth =8264 - LayoutCachedHeight =5483 End Begin TextBox Locked = NotDefault @@ -420,22 +361,13 @@ Begin Form OverlapFlags =85 TextAlign =1 IMESentenceMode =3 - Left =5674 - Top =1251 + Left =5700 + Top =1260 Width =4380 Height =300 TabIndex =7 Name ="txtCurrentLetterCase" Format ="@;;---" - ConditionalFormat = Begin - 0x01000000dc000000020000000100000000000000000000001200000001000000 , - 0xbfbfbf00ffffff000100000000000000130000003d00000001010000ba141900 , - 0xffffff0000000000000000000000000000000000000000000000000000000000 , - 0x5b0074007800740057006f00720064005d0020004900730020004e0075006c00 , - 0x6c000000000053007400720043006f006d00700028005b007400780074005700 , - 0x6f00720064005d002c005b00740078007400430075007200720065006e007400 , - 0x560061006c00750065005d002c00300029003c003e00300000000000 - End GroupTable =1 TopPadding =0 GridlineWidthLeft =0 @@ -444,30 +376,17 @@ Begin Form GridlineWidthBottom =0 HorizontalAnchor =1 - LayoutCachedLeft =5674 - LayoutCachedTop =1251 - LayoutCachedWidth =10054 - LayoutCachedHeight =1551 RowStart =2 RowEnd =2 ColumnEnd =1 LayoutGroup =1 - ConditionalFormat14 = Begin - 0x010002000000010000000000000001000000bfbfbf00ffffff00110000005b00 , - 0x74007800740057006f00720064005d0020004900730020004e0075006c006c00 , - 0x0000000000000000000000000000000000000000000100000000000000010100 , - 0x00ba141900ffffff002900000053007400720043006f006d00700028005b0074 , - 0x007800740057006f00720064005d002c005b0074007800740043007500720072 , - 0x0065006e007400560061006c00750065005d002c00300029003c003e00300000 , - 0x0000000000000000000000000000000000000000 - End GroupTable =1 End Begin Label OverlapFlags =85 TextAlign =1 - Left =5674 - Top =951 + Left =5700 + Top =960 Width =4380 Height =300 Name ="Label19" @@ -475,10 +394,6 @@ Begin Form GroupTable =1 BottomPadding =0 HorizontalAnchor =1 - LayoutCachedLeft =5674 - LayoutCachedTop =951 - LayoutCachedWidth =10054 - LayoutCachedHeight =1251 RowStart =1 RowEnd =1 ColumnEnd =1 @@ -488,8 +403,8 @@ Begin Form Begin Label OverlapFlags =85 TextAlign =1 - Left =5674 - Top =1611 + Left =5700 + Top =1620 Width =4380 Height =300 Name ="Label20" @@ -497,10 +412,6 @@ Begin Form GroupTable =1 BottomPadding =0 HorizontalAnchor =1 - LayoutCachedLeft =5674 - LayoutCachedTop =1611 - LayoutCachedWidth =10054 - LayoutCachedHeight =1911 RowStart =3 RowEnd =3 ColumnEnd =1 @@ -513,44 +424,28 @@ Begin Form OverlapFlags =85 TextAlign =1 IMESentenceMode =3 - Left =5674 - Top =3626 - Width =3403 - Height =343 + Left =5700 + Top =3660 + Width =3420 + Height =360 TabIndex =9 Name ="txtSelectedLetterCase" ControlSource ="=[lbVariations]" Format ="@;;---" - ConditionalFormat = Begin - 0x0100000086000000010000000100000000000000000000001200000001000000 , - 0xbfbfbf00ffffff00000000000000000000000000000000000000000000000000 , - 0x0000000000000000000000000000000000000000000000000000000000000000 , - 0x5b0074007800740057006f00720064005d0020004900730020004e0075006c00 , - 0x6c0000000000 - End GroupTable =1 TopPadding =0 HorizontalAnchor =1 - LayoutCachedLeft =5674 - LayoutCachedTop =3626 - LayoutCachedWidth =9077 - LayoutCachedHeight =3969 RowStart =6 RowEnd =6 LayoutGroup =1 - ConditionalFormat14 = Begin - 0x010001000000010000000000000001000000bfbfbf00ffffff00110000005b00 , - 0x74007800740057006f00720064005d0020004900730020004e0075006c006c00 , - 0x000000000000000000000000000000000000000000 - End GroupTable =1 End Begin Label OverlapFlags =85 TextAlign =1 - Left =5674 - Top =3291 + Left =5700 + Top =3300 Width =4380 Height =300 Name ="Label45" @@ -558,10 +453,6 @@ Begin Form GroupTable =1 TopPadding =0 HorizontalAnchor =1 - LayoutCachedLeft =5674 - LayoutCachedTop =3291 - LayoutCachedWidth =10054 - LayoutCachedHeight =3591 RowStart =5 RowEnd =5 ColumnEnd =1 @@ -571,10 +462,10 @@ Begin Form Begin CommandButton Enabled = NotDefault OverlapFlags =85 - Left =9137 - Top =3626 - Width =917 - Height =343 + Left =9180 + Top =3660 + Width =900 + Height =360 TabIndex =10 Name ="cmdChangeLetterCase" Caption ="Commit" @@ -583,10 +474,6 @@ Begin Form TopPadding =0 HorizontalAnchor =1 - LayoutCachedLeft =9137 - LayoutCachedTop =3626 - LayoutCachedWidth =10054 - LayoutCachedHeight =3969 RowStart =6 RowEnd =6 ColumnStart =1 @@ -604,9 +491,9 @@ Begin Form End Begin CommandButton OverlapFlags =85 - Left =3754 - Top =5443 - Width =1697 + Left =3720 + Top =5460 + Width =1680 Height =300 TabIndex =13 Name ="cmdSaveToTable" @@ -614,10 +501,6 @@ Begin Form OnClick ="[Event Procedure]" GroupTable =2 - LayoutCachedLeft =3754 - LayoutCachedTop =5443 - LayoutCachedWidth =5451 - LayoutCachedHeight =5743 ColumnStart =2 ColumnEnd =2 LayoutGroup =2 @@ -633,9 +516,9 @@ Begin Form End Begin CommandButton OverlapFlags =85 - Left =1997 - Top =5443 - Width =1697 + Left =1980 + Top =5460 + Width =1680 Height =300 TabIndex =12 Name ="cmdLoadFromTable" @@ -643,10 +526,6 @@ Begin Form OnClick ="[Event Procedure]" GroupTable =2 - LayoutCachedLeft =1997 - LayoutCachedTop =5443 - LayoutCachedWidth =3694 - LayoutCachedHeight =5743 ColumnStart =1 ColumnEnd =1 LayoutGroup =2 @@ -664,17 +543,13 @@ Begin Form OverlapFlags =85 TextAlign =1 Left =60 - Top =5443 - Width =1875 + Top =5460 + Width =1860 Height =300 FontSize =10 Name ="Label56" Caption ="Table: USysDeclDict" GroupTable =2 - LayoutCachedLeft =60 - LayoutCachedTop =5443 - LayoutCachedWidth =1935 - LayoutCachedHeight =5743 LayoutGroup =2 GroupTable =2 End @@ -689,10 +564,6 @@ Begin Form LeftMargin =57 Name ="lblTableRecInfo" HorizontalAnchor =2 - LayoutCachedLeft =5503 - LayoutCachedTop =5563 - LayoutCachedWidth =10028 - LayoutCachedHeight =6103 ForeThemeColorIndex =2 ForeTint =100.0 End @@ -706,10 +577,6 @@ Begin Form FontSize =8 Name ="lblVersionInfo" HorizontalAnchor =2 - LayoutCachedLeft =5494 - LayoutCachedTop =5897 - LayoutCachedWidth =10044 - LayoutCachedHeight =6120 End Begin TextBox OverlapFlags =87 @@ -722,10 +589,6 @@ Begin Form Name ="filtWord" AfterUpdate ="[Event Procedure]" - LayoutCachedLeft =720 - LayoutCachedTop =446 - LayoutCachedWidth =3793 - LayoutCachedHeight =746 Begin Begin Label OverlapFlags =95 @@ -735,10 +598,6 @@ Begin Form Height =300 Name ="Label67" Caption ="Filter:" - LayoutCachedLeft =60 - LayoutCachedTop =446 - LayoutCachedWidth =720 - LayoutCachedHeight =746 End End End @@ -754,10 +613,6 @@ Begin Form OnClick ="[Event Procedure]" BackStyle =0 - LayoutCachedLeft =3981 - LayoutCachedTop =429 - LayoutCachedWidth =5476 - LayoutCachedHeight =757 ForeThemeColorIndex =0 GridlineThemeColorIndex =1 Gradient =0 @@ -771,20 +626,16 @@ Begin Form End Begin CommandButton OverlapFlags =85 - Left =3754 - Top =5803 - Width =1697 - Height =317 + Left =3720 + Top =5820 + Width =1680 + Height =300 TabIndex =15 Name ="cmdSaveToFile" Caption ="Export to file" OnClick ="[Event Procedure]" GroupTable =2 - LayoutCachedLeft =3754 - LayoutCachedTop =5803 - LayoutCachedWidth =5451 - LayoutCachedHeight =6120 RowStart =1 RowEnd =1 ColumnStart =2 @@ -802,20 +653,16 @@ Begin Form End Begin CommandButton OverlapFlags =85 - Left =1997 - Top =5803 - Width =1697 - Height =317 + Left =1980 + Top =5820 + Width =1680 + Height =300 TabIndex =14 Name ="cmdLoadFromFile" Caption ="Load from file" OnClick ="[Event Procedure]" GroupTable =2 - LayoutCachedLeft =1997 - LayoutCachedTop =5803 - LayoutCachedWidth =3694 - LayoutCachedHeight =6120 RowStart =1 RowEnd =1 ColumnStart =1 @@ -835,17 +682,13 @@ Begin Form OverlapFlags =85 TextAlign =1 Left =60 - Top =5803 - Width =1875 - Height =317 + Top =5820 + Width =1860 + Height =300 FontSize =10 Name ="Bezeichnungsfeld71" Caption ="File: DeclarationDict" GroupTable =2 - LayoutCachedLeft =60 - LayoutCachedTop =5803 - LayoutCachedWidth =1935 - LayoutCachedHeight =6120 RowStart =1 RowEnd =1 LayoutGroup =2 @@ -900,10 +743,6 @@ Begin Form 0x0000000000000000 End - LayoutCachedLeft =9008 - LayoutCachedTop =56 - LayoutCachedWidth =10034 - LayoutCachedHeight =453 PictureCaptionArrangement =5 ForeThemeColorIndex =0 GridlineThemeColorIndex =1 diff --git a/source/forms/DeclarationDictForm.json b/source/forms/DeclarationDictForm.json new file mode 100644 index 0000000..eb5a69e --- /dev/null +++ b/source/forms/DeclarationDictForm.json @@ -0,0 +1,62 @@ +{ + "Info": { + "Class": "clsDbForm", + "Description": "DeclarationDictForm Conditional Formatting" + }, + "Items": { + "ConditionalFormatting": { + "txtWord": { + "Rules": [ + { + "Type": "Expression", + "Enabled": true, + "FontBold": false, + "FontItalic": false, + "FontUnderline": false, + "ForeColor": "RGB(191,191,191)", + "BackColor": "RGB(255,255,255)", + "Expression1": "[txtWord] Is Null" + } + ] + }, + "txtCurrentLetterCase": { + "Rules": [ + { + "Type": "Expression", + "Enabled": true, + "FontBold": false, + "FontItalic": false, + "FontUnderline": false, + "ForeColor": "RGB(191,191,191)", + "BackColor": "RGB(255,255,255)", + "Expression1": "[txtWord] Is Null" + }, + { + "Type": "Expression", + "Enabled": true, + "FontBold": true, + "FontItalic": false, + "FontUnderline": false, + "ForeColor": "RGB(186,20,25)", + "BackColor": "RGB(255,255,255)", + "Expression1": "StrComp([txtWord],[txtCurrentValue],0)<>0" + } + ] + }, + "txtSelectedLetterCase": { + "Rules": [ + { + "Type": "Expression", + "Enabled": true, + "FontBold": false, + "FontItalic": false, + "FontUnderline": false, + "ForeColor": "RGB(191,191,191)", + "BackColor": "RGB(255,255,255)", + "Expression1": "[txtWord] Is Null" + } + ] + } + } + } +} diff --git a/source/forms/InfoFormAPI.bas b/source/forms/InfoFormAPI.form similarity index 95% rename from source/forms/InfoFormAPI.bas rename to source/forms/InfoFormAPI.form index 94c7565..2d4e373 100644 --- a/source/forms/InfoFormAPI.bas +++ b/source/forms/InfoFormAPI.form @@ -21,10 +21,10 @@ Begin Form Width =9072 DatasheetFontHeight =11 ItemSuffix =4 - Left =7620 - Top =3045 - Right =20775 - Bottom =14775 + Left =1000 + Top =1000 + Right =50000 + Bottom =50000 RecSrcDt = Begin 0x9487851a5859e640 End @@ -105,8 +105,6 @@ Begin Form HorizontalAnchor =2 VerticalAnchor =2 - LayoutCachedWidth =9072 - LayoutCachedHeight =6804 End End End diff --git a/source/forms/InstallAddInForm.bas b/source/forms/InstallAddInForm.form similarity index 80% rename from source/forms/InstallAddInForm.bas rename to source/forms/InstallAddInForm.form index abb1400..a01953f 100644 --- a/source/forms/InstallAddInForm.bas +++ b/source/forms/InstallAddInForm.form @@ -17,13 +17,13 @@ Begin Form PictureAlignment =2 DatasheetGridlinesBehavior =3 GridY =10 - Width =7386 + Width =7380 DatasheetFontHeight =11 ItemSuffix =335 - Left =7620 - Top =3045 - Right =20775 - Bottom =14775 + Left =1000 + Top =1000 + Right =50000 + Bottom =50000 RecSrcDt = Begin 0x956642cd6e4ee640 End @@ -140,7 +140,7 @@ Begin Form GridlineShade =65.0 End Begin Section - Height =7278 + Height =7260 Name ="Detailbereich" AlternateBackThemeColorIndex =1 AlternateBackShade =95.0 @@ -152,8 +152,8 @@ Begin Form OverlapFlags =85 TextAlign =1 IMESentenceMode =3 - Left =2074 - Top =3137 + Left =2100 + Top =3240 Width =4740 Height =300 TabIndex =5 @@ -164,10 +164,6 @@ Begin Form BottomPadding =150 ShowDatePicker =0 - LayoutCachedLeft =2074 - LayoutCachedTop =3137 - LayoutCachedWidth =6814 - LayoutCachedHeight =3437 RowStart =6 RowEnd =6 ColumnStart =1 @@ -179,8 +175,8 @@ Begin Form Begin Label OverlapFlags =85 TextAlign =1 - Left =574 - Top =3137 + Left =600 + Top =3240 Width =1440 Height =300 Name ="lbltxtAddInName" @@ -190,10 +186,6 @@ Begin Form LeftPadding =57 BottomPadding =150 HorizontalAnchor =2 - LayoutCachedLeft =574 - LayoutCachedTop =3137 - LayoutCachedWidth =2014 - LayoutCachedHeight =3437 RowStart =6 RowEnd =6 LayoutGroup =1 @@ -209,8 +201,8 @@ Begin Form OverlapFlags =85 TextAlign =1 IMESentenceMode =3 - Left =2074 - Top =574 + Left =2100 + Top =600 Width =4740 Height =300 TabIndex =1 @@ -221,10 +213,6 @@ Begin Form BottomPadding =150 ShowDatePicker =0 - LayoutCachedLeft =2074 - LayoutCachedTop =574 - LayoutCachedWidth =6814 - LayoutCachedHeight =874 ColumnStart =1 ColumnEnd =2 LayoutGroup =1 @@ -234,8 +222,8 @@ Begin Form Begin Label OverlapFlags =85 TextAlign =1 - Left =574 - Top =574 + Left =600 + Top =600 Width =1440 Height =300 Name ="lblFileName" @@ -245,10 +233,6 @@ Begin Form LeftPadding =57 BottomPadding =150 HorizontalAnchor =2 - LayoutCachedLeft =574 - LayoutCachedTop =574 - LayoutCachedWidth =2014 - LayoutCachedHeight =874 LayoutGroup =1 ThemeFontIndex =-1 GroupTable =1 @@ -261,8 +245,8 @@ Begin Form OverlapFlags =85 TextAlign =1 IMESentenceMode =3 - Left =2074 - Top =3617 + Left =2100 + Top =3720 Width =4740 Height =300 TabIndex =6 @@ -273,10 +257,6 @@ Begin Form BottomPadding =150 ShowDatePicker =0 - LayoutCachedLeft =2074 - LayoutCachedTop =3617 - LayoutCachedWidth =6814 - LayoutCachedHeight =3917 RowStart =7 RowEnd =7 ColumnStart =1 @@ -288,8 +268,8 @@ Begin Form Begin Label OverlapFlags =85 TextAlign =1 - Left =574 - Top =3617 + Left =600 + Top =3720 Width =1440 Height =300 Name ="lblAddInAuthor" @@ -299,10 +279,6 @@ Begin Form LeftPadding =57 BottomPadding =150 HorizontalAnchor =2 - LayoutCachedLeft =574 - LayoutCachedTop =3617 - LayoutCachedWidth =2014 - LayoutCachedHeight =3917 RowStart =7 RowEnd =7 LayoutGroup =1 @@ -317,8 +293,8 @@ Begin Form OverlapFlags =85 TextAlign =1 IMESentenceMode =3 - Left =2074 - Top =4097 + Left =2100 + Top =4200 Width =4740 Height =300 TabIndex =7 @@ -329,10 +305,6 @@ Begin Form BottomPadding =150 ShowDatePicker =0 - LayoutCachedLeft =2074 - LayoutCachedTop =4097 - LayoutCachedWidth =6814 - LayoutCachedHeight =4397 RowStart =8 RowEnd =8 ColumnStart =1 @@ -344,8 +316,8 @@ Begin Form Begin Label OverlapFlags =85 TextAlign =1 - Left =574 - Top =4097 + Left =600 + Top =4200 Width =1440 Height =300 Name ="lblAddInCompany" @@ -355,10 +327,6 @@ Begin Form LeftPadding =57 BottomPadding =150 HorizontalAnchor =2 - LayoutCachedLeft =574 - LayoutCachedTop =4097 - LayoutCachedWidth =2014 - LayoutCachedHeight =4397 RowStart =8 RowEnd =8 LayoutGroup =1 @@ -373,10 +341,10 @@ Begin Form OverlapFlags =85 TextAlign =1 IMESentenceMode =3 - Left =2074 - Top =4577 + Left =2100 + Top =4680 Width =4740 - Height =1123 + Height =1140 TabIndex =8 Name ="txtAddInComment" FontName ="Tahoma" @@ -386,10 +354,6 @@ Begin Form VerticalAnchor =2 ShowDatePicker =0 - LayoutCachedLeft =2074 - LayoutCachedTop =4577 - LayoutCachedWidth =6814 - LayoutCachedHeight =5700 RowStart =9 RowEnd =9 ColumnStart =1 @@ -401,10 +365,10 @@ Begin Form Begin Label OverlapFlags =85 TextAlign =1 - Left =574 - Top =4577 + Left =600 + Top =4680 Width =1440 - Height =1123 + Height =1140 Name ="lblAddInComment" Caption ="Comment" FontName ="Tahoma" @@ -413,10 +377,6 @@ Begin Form BottomPadding =150 HorizontalAnchor =2 VerticalAnchor =2 - LayoutCachedLeft =574 - LayoutCachedTop =4577 - LayoutCachedWidth =2014 - LayoutCachedHeight =5700 RowStart =9 RowEnd =9 LayoutGroup =1 @@ -427,10 +387,10 @@ Begin Form End Begin CommandButton OverlapFlags =85 - Left =574 - Top =6240 + Left =600 + Top =6360 Width =6240 - Height =450 + Height =480 TabIndex =10 Name ="cmdInstallAddIn" Caption ="Install Add-in" @@ -441,10 +401,6 @@ Begin Form BottomPadding =567 HorizontalAnchor =2 - LayoutCachedLeft =574 - LayoutCachedTop =6240 - LayoutCachedWidth =6814 - LayoutCachedHeight =6690 RowStart =11 RowEnd =11 ColumnEnd =2 @@ -457,10 +413,10 @@ Begin Form OverlapFlags =85 TextAlign =1 IMESentenceMode =3 - Left =2074 - Top =2340 + Left =2100 + Top =2400 Width =4740 - Height =291 + Height =300 TabIndex =4 Name ="txtAddInStartFunction" FontName ="Tahoma" @@ -469,10 +425,6 @@ Begin Form BottomPadding =150 ShowDatePicker =0 - LayoutCachedLeft =2074 - LayoutCachedTop =2340 - LayoutCachedWidth =6814 - LayoutCachedHeight =2631 RowStart =4 RowEnd =4 ColumnStart =1 @@ -484,10 +436,10 @@ Begin Form Begin Label OverlapFlags =85 TextAlign =1 - Left =574 - Top =2340 + Left =600 + Top =2400 Width =1440 - Height =291 + Height =300 Name ="lblAddInStartFunction" Caption ="Start Function" FontName ="Tahoma" @@ -495,10 +447,6 @@ Begin Form LeftPadding =57 BottomPadding =150 HorizontalAnchor =2 - LayoutCachedLeft =574 - LayoutCachedTop =2340 - LayoutCachedWidth =2014 - LayoutCachedHeight =2631 RowStart =4 RowEnd =4 LayoutGroup =1 @@ -513,8 +461,8 @@ Begin Form OverlapFlags =85 TextAlign =1 IMESentenceMode =3 - Left =2074 - Top =1860 + Left =2100 + Top =1920 Width =4740 Height =300 TabIndex =3 @@ -525,10 +473,6 @@ Begin Form BottomPadding =150 ShowDatePicker =0 - LayoutCachedLeft =2074 - LayoutCachedTop =1860 - LayoutCachedWidth =6814 - LayoutCachedHeight =2160 RowStart =3 RowEnd =3 ColumnStart =1 @@ -540,8 +484,8 @@ Begin Form Begin Label OverlapFlags =85 TextAlign =1 - Left =574 - Top =1860 + Left =600 + Top =1920 Width =1440 Height =300 Name ="Bezeichnungsfeld105" @@ -551,10 +495,6 @@ Begin Form LeftPadding =57 BottomPadding =150 HorizontalAnchor =2 - LayoutCachedLeft =574 - LayoutCachedTop =1860 - LayoutCachedWidth =2014 - LayoutCachedHeight =2160 RowStart =3 RowEnd =3 LayoutGroup =1 @@ -567,8 +507,8 @@ Begin Form FontUnderline = NotDefault OverlapFlags =85 TextAlign =1 - Left =574 - Top =1534 + Left =600 + Top =1560 Width =6240 Height =300 FontWeight =700 @@ -580,10 +520,6 @@ Begin Form RightPadding =567 BottomPadding =0 HorizontalAnchor =2 - LayoutCachedLeft =574 - LayoutCachedTop =1534 - LayoutCachedWidth =6814 - LayoutCachedHeight =1834 RowStart =2 RowEnd =2 ColumnEnd =2 @@ -595,8 +531,8 @@ Begin Form FontUnderline = NotDefault OverlapFlags =85 TextAlign =1 - Left =574 - Top =2811 + Left =600 + Top =2880 Width =6240 Height =300 FontWeight =700 @@ -608,10 +544,6 @@ Begin Form RightPadding =567 BottomPadding =0 HorizontalAnchor =2 - LayoutCachedLeft =574 - LayoutCachedTop =2811 - LayoutCachedWidth =6814 - LayoutCachedHeight =3111 RowStart =5 RowEnd =5 ColumnEnd =2 @@ -625,8 +557,8 @@ Begin Form OverlapFlags =85 TextAlign =1 IMESentenceMode =3 - Left =2074 - Top =1054 + Left =2100 + Top =1080 Width =4740 Height =300 TabIndex =2 @@ -637,10 +569,6 @@ Begin Form BottomPadding =150 ShowDatePicker =0 - LayoutCachedLeft =2074 - LayoutCachedTop =1054 - LayoutCachedWidth =6814 - LayoutCachedHeight =1354 RowStart =1 RowEnd =1 ColumnStart =1 @@ -652,8 +580,8 @@ Begin Form Begin Label OverlapFlags =85 TextAlign =1 - Left =574 - Top =1054 + Left =600 + Top =1080 Width =1440 Height =300 Name ="Label247" @@ -663,10 +591,6 @@ Begin Form LeftPadding =57 BottomPadding =150 HorizontalAnchor =2 - LayoutCachedLeft =574 - LayoutCachedTop =1054 - LayoutCachedWidth =2014 - LayoutCachedHeight =1354 RowStart =1 RowEnd =1 LayoutGroup =1 @@ -686,9 +610,9 @@ Begin Form End Begin CheckBox OverlapFlags =85 - Left =3017 - Top =5880 - Width =3797 + Left =3060 + Top =6000 + Width =3780 Height =300 TabIndex =9 Name ="cbCompileAddIn" @@ -696,10 +620,6 @@ Begin Form GroupTable =1 RightPadding =567 - LayoutCachedLeft =3017 - LayoutCachedTop =5880 - LayoutCachedWidth =6814 - LayoutCachedHeight =6180 RowStart =10 RowEnd =10 ColumnStart =2 @@ -710,9 +630,9 @@ Begin Form Begin Label OverlapFlags =85 TextAlign =1 - Left =574 - Top =5880 - Width =2417 + Left =600 + Top =6000 + Width =2400 Height =300 ForeColor =0 Name ="Label325" @@ -721,10 +641,6 @@ Begin Form LeftPadding =57 RightPadding =0 HorizontalAnchor =2 - LayoutCachedLeft =574 - LayoutCachedTop =5880 - LayoutCachedWidth =2991 - LayoutCachedHeight =6180 RowStart =10 RowEnd =10 ColumnEnd =1 @@ -744,10 +660,6 @@ Begin Form FontSize =8 Name ="lblVersionInfo" HorizontalAnchor =2 - LayoutCachedLeft =114 - LayoutCachedTop =6916 - LayoutCachedWidth =7253 - LayoutCachedHeight =7139 End Begin CommandButton OverlapFlags =85 @@ -797,10 +709,6 @@ Begin Form 0x0000000000000000 End - LayoutCachedLeft =6179 - LayoutCachedTop =113 - LayoutCachedWidth =7205 - LayoutCachedHeight =510 PictureCaptionArrangement =5 End End diff --git a/source/modVbProject.bas b/source/modVbProject.bas new file mode 100644 index 0000000..c1a3705 --- /dev/null +++ b/source/modVbProject.bas @@ -0,0 +1,92 @@ +Attribute VB_Name = "modVbProject" +'--------------------------------------------------------------------------------------- +' Module: modVbProject +'--------------------------------------------------------------------------------------- +'/** +' +' VBProject ermitteln +' +' +' +' \ingroup base +'**/ +'--------------------------------------------------------------------------------------- +' +' %AppFolder%/source/modVbProject.bas +' _codelib/license.bas +' +'--------------------------------------------------------------------------------------- +' +Option Compare Text +Option Explicit +Option Private Module + +#Const EARLYBINDING = 1 + +Private m_CurrentVbProject As Object + +#If EARLYBINDING Then +Public Property Get CurrentVbProject() As VBIDE.VBProject +#Else +Public Property Get CurrentVbProject() As Object +#End If + +#If EARLYBINDING Then + Dim Proj As VBProject +#Else + Dim Proj As Object +#End If + Dim strCurrentDbName As String + + If m_CurrentVbProject Is Nothing Then + Set m_CurrentVbProject = Application.VBE.ActiveVBProject + If Application.VBE.VBProjects.Count > 1 Then + 'Prüfen, ob das richtige VbProject gewählt wurde (muss das von CurrentDb sein) + strCurrentDbName = UncPath(CurrentDb.Name) + If m_CurrentVbProject.FileName <> strCurrentDbName Then + Set m_CurrentVbProject = Nothing + For Each Proj In VBE.VBProjects + If Proj.FileName = strCurrentDbName Then + Set m_CurrentVbProject = Proj + Exit For + End If + Next + End If + End If + End If + + Set CurrentVbProject = m_CurrentVbProject + +End Property + + +#If EARLYBINDING Then +Public Property Get CodeVBProject() As VBIDE.VBProject +#Else +Public Property Get CodeVBProject() As Object +#End If + +#If EARLYBINDING Then + Dim Proj As VBProject +#Else + Dim Proj As Object +#End If + Dim strCodeDbName As String + Dim objCodeVbProject As Object + + Set objCodeVbProject = VBE.ActiveVBProject + 'Prüfen, ob das richtige VbProject gewählt wurde (muss das von CodeDb sein) + strCodeDbName = FileTools.UncPath(CodeDb.Name) + If objCodeVbProject.FileName <> strCodeDbName Then + Set objCodeVbProject = Nothing + For Each Proj In VBE.VBProjects + If Proj.FileName = strCodeDbName Then + Set objCodeVbProject = Proj + Exit For + End If + Next + End If + + Set CodeVBProject = objCodeVbProject + +End Property diff --git a/source/modules/CodeModulGenerator.cls b/source/modules/CodeModulGenerator.cls index 60eace2..aa99f4a 100644 --- a/source/modules/CodeModulGenerator.cls +++ b/source/modules/CodeModulGenerator.cls @@ -7,7 +7,7 @@ Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = False Attribute VB_Exposed = False -Option Compare Database +Option Compare Text Option Explicit Private m_VBComponent As VBComponent diff --git a/source/modules/CodemoduleDeclarationReader.cls b/source/modules/CodemoduleDeclarationReader.cls new file mode 100644 index 0000000..47cfcd9 --- /dev/null +++ b/source/modules/CodemoduleDeclarationReader.cls @@ -0,0 +1,231 @@ +VERSION 1.0 CLASS +BEGIN + MultiUse = -1 'True +END +Attribute VB_Name = "CodemoduleDeclarationReader" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = False +Attribute VB_PredeclaredId = False +Attribute VB_Exposed = False +Option Compare Text +Option Explicit + +Private m_DeclDict As DeclarationDict + +Public Sub ImportVBProject(ByVal VBProject2Import As VBProject, ByVal DeclDict As DeclarationDict, Optional ByVal IncludeUsedMembers As Boolean = False) + + Dim vbc As VBComponent + + For Each vbc In VBProject2Import.VBComponents + ImportVBComponent vbc, DeclDict, IncludeUsedMembers + Next + +End Sub + +Public Sub ImportVBComponent(ByVal VBComponent2Import As VBComponent, ByVal DeclDict As DeclarationDict, Optional ByVal IncludeUsedMembers As Boolean = False) + ImportCodeModule VBComponent2Import.CodeModule, DeclDict, IncludeUsedMembers +End Sub + +Public Sub ImportCodeModule(ByVal CodeModule2Import As CodeModule, ByVal DeclDict As DeclarationDict, Optional ByVal IncludeUsedMembers As Boolean = False) + If CodeModule2Import.CountOfLines > 0 Then + ImportCode CodeModule2Import.Lines(1, CodeModule2Import.CountOfLines), DeclDict, IncludeUsedMembers + End If +End Sub + +Public Sub ImportCode(ByVal Code As String, ByVal DeclDict As DeclarationDict, Optional ByVal IncludeUsedMembers As Boolean = False) + + Dim RegEx As RegExp + Set RegEx = NewRegExp + + Set m_DeclDict = DeclDict + + Code = PrepareCode(Code, RegEx) + + Const ProcIndex As Long = 0 + Const EnumTypeIndex As Long = 1 + Const DimIndex As Long = 2 + + Dim Patterns() As String + ReDim Patterns(2 + Abs(IncludeUsedMembers)) As String + + Patterns(ProcIndex) = "(?:\r|\n|^)\s*(?:Sub|Function|Property Get|Property Let|Property Set|Event)\s+([^\r\n]*)" + Patterns(EnumTypeIndex) = "(?:\r|\n|^)\s*(?:Enum|Type)([\s\S]*?)(?:End\s+(?:Enum|Type))" + Patterns(2) = "(?:\r|\n|^)\s*(?:Dim|ReDim|Private|Friend|Public|Const|Static|Global|Implements)\s+([^\r\n]*)" + If IncludeUsedMembers Then + 'see: https://github.com/hrschupp/ACLibDeclarationDictionaryCore/commit/861031d695c236f3b7872f191e2d3a1570d35fca#diff-0a954b2b22b447d5669ac2cc27824aef945ba74307ebf8c3c3c2c5dc67080afa + Patterns(3) = "(?:[.!])([^0-9\s.!_\(\)\[\]\r\n][^\s.!\(\)\[\]\r\n]*)(?:\s|[.!\(\)\[\]\r\n]|$)" + End If + + Dim i As Long + For i = 0 To UBound(Patterns) + RegEx.Pattern = Patterns(i) + AddFromCode Code, RegEx, i = ProcIndex, i = EnumTypeIndex, i = DimIndex + Next + +End Sub + +Private Function NewRegExp() As RegExp + + Dim RegEx As RegExp + + Set RegEx = New RegExp + RegEx.IgnoreCase = True + RegEx.Global = True + + Set NewRegExp = RegEx + +End Function + +Private Function PrepareCode(ByVal Code As String, ByVal RegEx As RegExp) As String + + Code = Replace(Code, " _" & vbNewLine, " ") + +#If DebugPrintEnabled Then + DebugPrint Code, True, "PrepareCode - after Replace ' _' & vbNewLine" +#End If + + With RegEx + + ' clear all strings + .Pattern = """[^""\r\n]*""" + Code = .Replace(Code, "") + + ' remove comments + '.Pattern = "'(.*)[\r\n]" + .Pattern = "'(.*)([\r\n]|$)" + Code = .Replace(Code, "$2") + +#If DebugPrintEnabled Then + DebugPrint Code, True, "PrepareCode- after remove comments" +#End If + + ' treat line labels as dim (but not line numbers) + .Pattern = "([\r\n]|^)([^0-9\r\n]\S*):(\s|[\r\n]|$)" + Code = .Replace(Code, "$1Dim $2:$3") + + ' dim a as String: a = 5 => insert line break + .Pattern = "(\:\s)" + Code = .Replace(Code, vbNewLine) + + ' remove Withevents + .Pattern = "(Public|Private|Friend|Global)\sWithEvents\s" + Code = .Replace(Code, "$1 ") + + ' API declaration => convert to normal procedure declaration + .Pattern = "(?:Declare PtrSafe)\s(Function|Sub)\s" + Code = .Replace(Code, "Declare $1 ") + + RegEx.Pattern = "(?:Declare)\s(Function|Sub)\s([^ ]*)[^(]*\(" + Code = .Replace(Code, "$1 $2(") + + ' remove Static before Function, Sub, Property, .. + .Pattern = "(?:Static)+\s(Function|Sub|Property)\s" + Code = .Replace(Code, "$1 ") + + ' remove Public, Private, Friend before Function, Sub, Property, .. + .Pattern = "(?:Public|Private|Friend|Global)\s(Function|Sub|Property|Event|Enum|Type|Const)\s" + Code = .Replace(Code, "$1 ") + + End With + +#If DebugPrintEnabled Then + DebugPrint Code, True, "PrepareCode - completed" +#End If + + PrepareCode = Code + +End Function + +Private Sub AddFromCode(ByVal Code As String, ByVal RegEx As RegExp, ByVal IsProcedure As Boolean, ByVal IsEnumTypeBlock As Boolean, ByVal IsDimBlock As Boolean) + + Dim Match As Match + Dim i As Long + + For Each Match In RegEx.Execute(Code) + For i = 0 To Match.SubMatches.Count - 1 + AddWordFromDeclaration Match.SubMatches(i), IsProcedure, IsEnumTypeBlock, IsDimBlock + Next + Next + +End Sub + +Private Sub AddWordFromDeclaration(ByRef Declarations As String, ByVal IsProcedure As Boolean, ByVal IsEnumTypeBlock As Boolean, ByVal IsDimBlock As Boolean) + + Dim Word As String + Dim i As Long + Dim Pos As Long + Dim PosX As Long + + Dim DeclArray() As String + + If IsEnumTypeBlock Then + Declarations = Replace(Declarations, vbCr, ",") + Declarations = Replace(Declarations, vbLf, vbNullString) + End If + + Declarations = Trim(Declarations) + + If IsProcedure Then + ' Debug.Print Declarations + Declarations = Replace(Declarations, "()", vbNullString) + Declarations = Replace(Declarations, "Optional ", vbNullString) + Declarations = Replace(Declarations, "ByRef ", vbNullString) + Declarations = Replace(Declarations, "ByVal ", vbNullString) + Declarations = Replace(Declarations, "ParamArray ", vbNullString) + + Pos = InStr(1, Declarations, "(") + If Pos > 0 Then + Mid(Declarations, Pos, 1) = "," + End If + Declarations = Replace(Declarations, ")", vbNullString) + End If + + Do While InStr(1, Declarations, " ") > 0 + Declarations = Replace(Declarations, " ", " ") + Loop + + If IsDimBlock Then + Do While Declarations Like "*(*,*)*" + ' prevent multi-dimensional Dim from transforming into new declarations (might be numeric) + Pos = InStr(1, Declarations, "(") + PosX = InStr(Pos, Declarations, ")") + Declarations = Left(Declarations, Pos - 1) & " " & Mid(Declarations, PosX + 1) + Loop + End If + + DeclArray = Split(Trim(Declarations), ",") + + For i = LBound(DeclArray) To UBound(DeclArray) + Word = Trim(DeclArray(i)) + Pos = CutPos(Word) + If Pos > 1 Then + Word = Trim(Left(Word, Pos - 1)) + End If + If Len(Word) > 0 Then + m_DeclDict.AddWord Word + End If + Next + +End Sub + +Private Function CutPos(ByVal Expression As String) As Long + + Dim Pos As Long + Dim PosX As Long + + Const CutChars As String = " ()" + + Dim i As Long + + For i = 1 To Len(CutChars) + PosX = InStr(1, Expression, Mid(CutChars, i, 1)) + If PosX > 0 Then + If Pos = 0 Or PosX < Pos Then + Pos = PosX + End If + End If + Next + + CutPos = Pos + +End Function diff --git a/source/modules/DeclarationDict.cls b/source/modules/DeclarationDict.cls index b743ce9..5c8fd5b 100644 --- a/source/modules/DeclarationDict.cls +++ b/source/modules/DeclarationDict.cls @@ -7,7 +7,7 @@ Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = False Attribute VB_Exposed = False -Option Compare Database +Option Compare Text Option Explicit #Const DebugPrintEnabled = 0 @@ -121,7 +121,9 @@ Public Sub AddWord(ByVal Word As String) If Not m_Words.Exists(Word) Then m_Words.Add Word, Word m_WordVariations.Add Word, GetNewDict(BinaryCompare) - RaiseInsert = True + m_WordVariations.Item(Word).Add Word, Word + RaiseEvent WordInserted(Word) + Exit Sub End If Set SubDict = m_WordVariations.Item(Word) @@ -139,240 +141,28 @@ Public Sub AddWord(ByVal Word As String) End If End With - If RaiseInsert Then - RaiseEvent WordInserted(Word) - ElseIf RaiseChanged Then + If RaiseChanged Then RaiseEvent WordChanged(Word) End If End Sub -Public Sub ImportVBProject(ByVal VBProject2Import As VBProject) - - Dim vbc As VBComponent - - For Each vbc In VBProject2Import.VBComponents - ImportVBComponent vbc - Next - -End Sub - -Public Sub ImportVBComponent(ByVal VBComponent2Import As VBComponent) - ImportCodeModule VBComponent2Import.CodeModule -End Sub - -Public Sub ImportCodeModule(ByVal CodeModule2Import As CodeModule) - If CodeModule2Import.CountOfLines > 0 Then - ImportCode CodeModule2Import.Lines(1, CodeModule2Import.CountOfLines) - End If -End Sub - -Public Sub ImportCode(ByVal Code As String) - - Dim RegEx As RegExp - Set RegEx = NewRegExp - - Code = PrepareCode(Code, RegEx) - - Const ProcIndex As Long = 0 - Const EnumTypeIndex As Long = 1 - - Dim Patterns(2) As String - - Patterns(ProcIndex) = "(?:\r|\n|^)\s*(?:Sub|Function|Property Get|Property Let|Property Set|Event)\s+([^\r\n]*)" - Patterns(EnumTypeIndex) = "(?:\r|\n|^)\s*(?:Enum|Type)([\s\S]*?)(?:End\s+(?:Enum|Type))" - Patterns(2) = "(?:\r|\n|^)\s*(?:Dim|ReDim|Private|Friend|Public|Const|Static|Global|Implements)\s+([^\r\n]*)" - - Dim i As Long - For i = 0 To UBound(Patterns) - RegEx.Pattern = Patterns(i) - AddFromCode Code, RegEx, i = ProcIndex, i = EnumTypeIndex - Next - -End Sub - -Private Function NewRegExp() As RegExp - - Dim RegEx As RegExp - - Set RegEx = New RegExp - RegEx.IgnoreCase = True - RegEx.Global = True - - Set NewRegExp = RegEx - -End Function - -Private Function PrepareCode(ByVal Code As String, ByVal RegEx As RegExp) As String - - Code = Replace(Code, " _" & vbNewLine, " ") - -#If DebugPrintEnabled Then - DebugPrint Code, True, "PrepareCode - after Replace ' _' & vbNewLine" -#End If - - With RegEx - - ' clear all strings - .Pattern = """[^""\r\n]*""" - Code = .Replace(Code, "") - - ' remove comments - '.Pattern = "'(.*)[\r\n]" - .Pattern = "'(.*)([\r\n]|$)" - Code = .Replace(Code, "$2") - -#If DebugPrintEnabled Then - DebugPrint Code, True, "PrepareCode- after remove comments" -#End If - - ' treat line labels as dim (but not line numbers) - .Pattern = "([\r\n]|^)([^0-9\r\n]\S*):(\s|[\r\n]|$)" - Code = .Replace(Code, "$1Dim $2:$3") - - ' dim a as String: a = 5 => insert line break - .Pattern = "(\:\s)" - Code = .Replace(Code, vbNewLine) - - ' remove Withevents - .Pattern = "(Public|Private|Friend|Global)\sWithEvents\s" - Code = .Replace(Code, "$1 ") - - ' API declaration => convert to normal procedure declaration - .Pattern = "(?:Declare PtrSafe)\s(Function|Sub)\s" - Code = .Replace(Code, "Declare $1 ") - - RegEx.Pattern = "(?:Declare)\s(Function|Sub)\s([^ ]*)[^(]*\(" - Code = .Replace(Code, "$1 $2(") - - ' remove Static before Function, Sub, Property, .. - .Pattern = "(?:Static)+\s(Function|Sub|Property)\s" - Code = .Replace(Code, "$1 ") - - ' remove Public, Private, Friend before Function, Sub, Property, .. - .Pattern = "(?:Public|Private|Friend|Global)\s(Function|Sub|Property|Event|Enum|Type|Const)\s" - Code = .Replace(Code, "$1 ") - - End With - -#If DebugPrintEnabled Then - DebugPrint Code, True, "PrepareCode - completed" -#End If - - PrepareCode = Code - -End Function - -Private Sub AddFromCode(ByVal Code As String, ByVal RegEx As RegExp, ByVal IsProcedure As Boolean, ByVal IsEnumTypeBlock As Boolean) - - Dim Match As Match - Dim i As Long - - For Each Match In RegEx.Execute(Code) - For i = 0 To Match.SubMatches.Count - 1 - AddWordFromDeclaration Match.SubMatches(i), IsProcedure, IsEnumTypeBlock - Next - Next - -End Sub - -Private Sub AddWordFromDeclaration(ByRef Declarations As String, ByVal IsProcedure As Boolean, ByVal IsEnumTypeBlock As Boolean) - - Dim Word As String - Dim i As Long - Dim Pos As Long - Dim PosX As Long - - Dim DeclArray() As String - - If IsEnumTypeBlock Then - Declarations = Replace(Declarations, vbCr, ",") - Declarations = Replace(Declarations, vbLf, vbNullString) - End If - - Declarations = Trim(Declarations) - - If IsProcedure Then - ' Debug.Print Declarations - Declarations = Replace(Declarations, "()", vbNullString) - Declarations = Replace(Declarations, "Optional ", vbNullString) - Declarations = Replace(Declarations, "ByRef ", vbNullString) - Declarations = Replace(Declarations, "ByVal ", vbNullString) - Declarations = Replace(Declarations, "ParamArray ", vbNullString) - - Pos = InStr(1, Declarations, "(") - If Pos > 0 Then - Mid(Declarations, Pos, 1) = "," - End If - Declarations = Replace(Declarations, ")", vbNullString) - End If - - Do While InStr(1, Declarations, " ") > 0 - Declarations = Replace(Declarations, " ", " ") - Loop - - If Not IsProcedure And Not IsEnumTypeBlock Then - Do While Declarations Like "*(*,*)*" - ' prevent multi-dimensional Dim from transforming into new declarations (might be numeric) - Pos = InStr(1, Declarations, "(") - PosX = InStr(Pos, Declarations, ")") - Declarations = Left(Declarations, Pos - 1) & " " & Mid(Declarations, PosX + 1) - Loop - End If - - DeclArray = Split(Trim(Declarations), ",") - - For i = LBound(DeclArray) To UBound(DeclArray) - Word = Trim(DeclArray(i)) - Pos = CutPos(Word) - If Pos > 1 Then - Word = Trim(Left(Word, Pos - 1)) - End If - If Len(Word) > 0 Then - AddWord Word - End If - Next - -End Sub - -Private Function CutPos(ByVal Expression As String) As Long - - Dim Pos As Long - Dim PosX As Long - - Const CutChars As String = " ()" - - Dim i As Long - - For i = 1 To Len(CutChars) - PosX = InStr(1, Expression, Mid(CutChars, i, 1)) - If PosX > 0 Then - If Pos = 0 Or PosX < Pos Then - Pos = PosX - End If - End If - Next - - CutPos = Pos - -End Function - Public Function ToString(Optional ByVal ShowAll As Boolean = False) As String - Dim WordKey As Variant + Dim IdxWordKey As Variant Dim WordIndex As Long - Dim VariationsDict As Scripting.Dictionary + Dim IdxVariationsDict As Scripting.Dictionary Dim OutputString As String For WordIndex = 0 To m_Words.Count - 1 - WordKey = m_Words.Keys(WordIndex) - Set VariationsDict = m_Words.Item(WordKey) + IdxWordKey = m_Words.Keys(WordIndex) + Set IdxVariationsDict = m_WordVariations.Item(IdxWordKey) - If VariationsDict.Count > (1 - Abs(ShowAll)) Then - OutputString = OutputString & vbNewLine & WordKey & ":" & GetWordVariationsOutputString(WordKey) + If IdxVariationsDict.Count > (1 - Abs(ShowAll)) Then + OutputString = OutputString & vbNewLine & IdxWordKey & ":" & GetWordVariationsOutputString(IdxWordKey, False) End If Next @@ -383,12 +173,12 @@ End Function Public Function ToDict(Optional ByVal ShowAll As Boolean = False) As Scripting.Dictionary - Dim WordKey As Variant + Dim IdxWordKey As Variant Dim WordIndex As Long Dim OutputWord As Boolean Dim VariationsString As String - Dim VariationsDict As Scripting.Dictionary + Dim IdxVariationsDict As Scripting.Dictionary Dim OutputDict As Scripting.Dictionary Set OutputDict = New Scripting.Dictionary @@ -397,19 +187,19 @@ Public Function ToDict(Optional ByVal ShowAll As Boolean = False) As Scripting.D For WordIndex = 0 To m_Words.Count - 1 - WordKey = m_Words.Keys(WordIndex) - Set VariationsDict = m_WordVariations.Item(WordKey) + IdxWordKey = m_Words.Keys(WordIndex) + Set IdxVariationsDict = m_WordVariations.Item(IdxWordKey) If Not ShowAll Then - OutputWord = IsChangedItem(WordKey, VariationsDict) + OutputWord = IsChangedItem(IdxWordKey, VariationsDict) End If If OutputWord Then - If VariationsDict.Count > 1 Then - VariationsString = GetWordVariationsOutputString(WordKey) + If IdxVariationsDict.Count > 1 Then + VariationsString = GetWordVariationsOutputString(IdxWordKey) Else VariationsString = vbNullString End If - OutputDict.Add WordKey, VariationsString + OutputDict.Add IdxWordKey, VariationsString End If Next @@ -430,19 +220,27 @@ Public Function GetWordVariations(ByVal Word As String, Optional ByVal IgnoreOri Dim VariantWord As String Dim AppendVariant As Boolean Dim i As Long, k As Long - Dim VariationsDict As Scripting.Dictionary + Dim WordVariationsDict As Scripting.Dictionary + Dim ResultCount As Long If StrComp(Word, m_Words.Item(Word), vbBinaryCompare) <> 0 Then Word = m_Words.Item(Word) End If - Set VariationsDict = m_WordVariations.Item(Word) - ReDim Variations(VariationsDict.Count - 1 - Abs(IgnoreOriginalWord)) + Set WordVariationsDict = m_WordVariations.Item(Word) + + ResultCount = WordVariationsDict.Count - Abs(IgnoreOriginalWord) + If ResultCount < 1 Then + GetWordVariations = Split(vbNullString) ' leeres String-Array + Exit Function + End If + + ReDim Variations(ResultCount - 1) AppendVariant = Not IgnoreOriginalWord - For i = 0 To VariationsDict.Count - 1 - VariantWord = VariationsDict.Keys(i) + For i = 0 To WordVariationsDict.Count - 1 + VariantWord = WordVariationsDict.Keys(i) If IgnoreOriginalWord Then AppendVariant = StrComp(Word, VariantWord, vbBinaryCompare) <> 0 End If @@ -472,6 +270,9 @@ Public Sub FixLetterCase(ByVal WordWithNewLetterCase As String) With New CodeModulGenerator .CreateCodemodule vbext_ct_StdModule + If Left(WordWithNewLetterCase, 1) = "_" Then + WordWithNewLetterCase = "[" & WordWithNewLetterCase & "]" + End If .InsertDeclarationLine "Private " & WordWithNewLetterCase .RemoveCodemodule End With diff --git a/source/modules/FileTools.bas b/source/modules/FileTools.bas index 4bfebf0..adaa21a 100644 --- a/source/modules/FileTools.bas +++ b/source/modules/FileTools.bas @@ -26,12 +26,12 @@ Option Private Module #If USELOCALIZATION_DE = 1 Then Private Const SELECTBOX_FILE_DIALOG_TITLE As String = "Datei auswählen" Private Const SELECTBOX_FOLDER_DIALOG_TITLE As String = "Ordner auswählen" -Private Const SELECTBOX_OPENTITLE As String = "auswählen" +Private Const SELECTBOX_OPENTITLE As String = "Auswählen" Private Const FILTERSTRING_ALL_FILES As String = "Alle Dateien (*.*)" #Else Private Const SELECTBOX_FILE_DIALOG_TITLE As String = "Select file" Private Const SELECTBOX_FOLDER_DIALOG_TITLE As String = "Select folder" -Private Const SELECTBOX_OPENTITLE As String = "auswählen" +Private Const SELECTBOX_OPENTITLE As String = "Select" Private Const FILTERSTRING_ALL_FILES As String = "All Files (*.*)" #End If @@ -43,8 +43,6 @@ Private Const SE_ERR_NOASSOC As Long = 31 Private Const VbaErrNo_FileNotFound As Long = 53 -#If VBA7 Then - Private Declare PtrSafe Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" ( _ ByVal lpszLocalName As String, ByVal lpszRemoteName As String, cbRemoteName As Long) As Long @@ -66,30 +64,6 @@ Private Declare PtrSafe Function API_ShellExecuteA Lib "shell32.dll" Alias "Shel ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long -#Else - -Private Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" ( _ - ByVal lpszLocalName As String, ByVal lpszRemoteName As String, cbRemoteName As Long) As Long - -Private Declare Function API_GetTempPath Lib "kernel32" Alias "GetTempPathA" ( _ - ByVal nBufferLength As Long, _ - ByVal lpBuffer As String) As Long - -Private Declare Function API_GetTempFilename Lib "kernel32" Alias "GetTempFileNameA" ( _ - ByVal lpszPath As String, _ - ByVal lpPrefixString As String, _ - ByVal wUnique As Long, _ - ByVal lpTempFileName As String) As Long - -Private Declare Function API_ShellExecuteA Lib "shell32.dll" Alias "ShellExecuteA" ( _ - ByVal Hwnd As Long, _ - ByVal lOperation As String, _ - ByVal lpFile As String, _ - ByVal lpParameters As String, _ - ByVal lpDirectory As String, _ - ByVal nShowCmd As Long) As Long - -#End If '--------------------------------------------------------------------------------------- ' Function: SelectFile @@ -753,7 +727,7 @@ Public Sub AddToZipFile(ByVal ZipFile As String, ByVal FullFileName As String) End If With CreateObject("Shell.Application") - .NameSpace(ZipFile & "").CopyHere FullFileName & "" + .Namespace(ZipFile & "").CopyHere FullFileName & "" End With End Sub @@ -775,8 +749,8 @@ End Sub Public Function ExtractFromZipFile(ByVal ZipFile As String, ByVal Destination As String) As String With CreateObject("Shell.Application") - .NameSpace(Destination & "").CopyHere .NameSpace(ZipFile & "").Items - ExtractFromZipFile = .NameSpace(ZipFile & "").Items.Item(0).Name + .Namespace(Destination & "").CopyHere .Namespace(ZipFile & "").Items + ExtractFromZipFile = .Namespace(ZipFile & "").Items.Item(0).Name End With End Function diff --git a/source/modules/_AddInAPI.bas b/source/modules/_AddInAPI.bas index eee2506..38faebf 100644 --- a/source/modules/_AddInAPI.bas +++ b/source/modules/_AddInAPI.bas @@ -30,11 +30,11 @@ End Function ' Function: RunVcsCheckDialog '--------------------------------------------------------------------------------------- ' -' Equal to RunVcsCheck(True) +' Equal to RunVcsCheck(True, vbNullString, True) ' '--------------------------------------------------------------------------------------- Public Function RunVcsCheckDialog() As Variant - RunVcsCheckDialog = RunVcsCheck(True) + RunVcsCheckDialog = RunVcsCheck(True, , True) End Function @@ -46,6 +46,8 @@ End Function ' ' Parameters: ' OpenDialogToFixLettercase - (Boolean) - Open dialog to fix lettercase +' DeclDictFilePath - (String) - Use alternative dictionary file path +' IncludeUsedMembers - (Boolean) - Also add used members to the dictionary (default: False) ' ' Returns: ' Boolean (True) ... if DiffCount = 0 @@ -54,7 +56,8 @@ End Function ' '--------------------------------------------------------------------------------------- Public Function RunVcsCheck(Optional ByVal OpenDialogToFixLettercase As Boolean = False, _ - Optional ByVal DeclDictFilePath As String = vbNullString) As Variant + Optional ByVal DeclDictFilePath As String = vbNullString, _ + Optional ByVal IncludeUsedMembers As Boolean = False) As Variant Dim CheckMsg As String Dim DiffCnt As Long @@ -62,52 +65,60 @@ Public Function RunVcsCheck(Optional ByVal OpenDialogToFixLettercase As Boolean Dim StoreDictData As Boolean Dim IntialCnt As Long - With New DeclarationDict + Dim DeclDict As DeclarationDict + Set DeclDict = New DeclarationDict - If Len(DeclDictFilePath) = 0 Then - DeclDictFilePath = CurrentProject.Path & "\" & CurrentProject.Name & ".DeclarationDict.txt" - End If + If Len(DeclDictFilePath) = 0 Then + DeclDictFilePath = CurrentProject.Path & "\" & CurrentProject.Name & ".DeclarationDict.txt" + End If - If Not .LoadFromFile(DeclDictFilePath) Then - .ImportVBProject CurrentVbProject - ' ... log info: first export - .ExportToFile DeclDictFilePath - RunVcsCheck = "Info: No dictionary data found. A new dictionary has been created." - Exit Function - End If + If Not DeclDict.LoadFromFile(DeclDictFilePath) Then + ImportVBProject CurrentVbProject, DeclDict, IncludeUsedMembers + ' ... log info: first export + DeclDict.ExportToFile DeclDictFilePath + RunVcsCheck = "Info: No dictionary data found. A new dictionary has been created." + Exit Function + End If - IntialCnt = .Count - .ImportVBProject CurrentVbProject + IntialCnt = DeclDict.Count + ImportVBProject CurrentVbProject, DeclDict, IncludeUsedMembers - DiffCnt = .DiffCount - If DiffCnt = 0 Then - If .Count <> IntialCnt Then - StoreDictData = True - End If + DiffCnt = DeclDict.DiffCount + If DiffCnt = 0 Then + If DeclDict.Count <> IntialCnt Then + StoreDictData = True End If + End If - If OpenDialogToFixLettercase Then - If DiffCnt > 0 Then - SetDeclarationDictTransferReference .Self - DoCmd.OpenForm "DeclarationDictApiDialog", , , , , acDialog - DiffCnt = .DiffCount - If DiffCnt = 0 Then - StoreDictData = True - End If + If OpenDialogToFixLettercase Then + If DiffCnt > 0 Then + SetDeclarationDictTransferReference DeclDict + DoCmd.OpenForm "DeclarationDictApiDialog", , , , , acDialog + DiffCnt = DeclDict.DiffCount + If DiffCnt = 0 Then + StoreDictData = True End If End If + End If - If StoreDictData Then - .ExportToFile DeclDictFilePath - End If + If StoreDictData Then + DeclDict.ExportToFile DeclDictFilePath + End If - If DiffCnt > 0 Then - CheckMsg = .DiffCount & " word" & IIf(.DiffCount > 1, "s", vbNullString) & " with different letter case" - RunVcsCheck = "Failed: " & CheckMsg - Else - RunVcsCheck = True - End If + If DiffCnt > 0 Then + CheckMsg = DeclDict.DiffCount & " word" & IIf(DeclDict.DiffCount > 1, "s", vbNullString) & " with different letter case" + RunVcsCheck = "Failed: " & CheckMsg + Else + RunVcsCheck = True + End If + +End Function + +Private Sub ImportVBProject(ByVal VbProjectToImport As VBIDE.VBProject, ByVal DeclDict As DeclarationDict, _ + Optional ByVal IncludeUsedMembers As Boolean = False) + With New CodemoduleDeclarationReader + .ImportVBProject VbProjectToImport, DeclDict, IncludeUsedMembers End With -End Function +End Sub diff --git a/source/modules/_config_Application.bas b/source/modules/_config_Application.bas index 5a3c570..c8d9f2c 100644 --- a/source/modules/_config_Application.bas +++ b/source/modules/_config_Application.bas @@ -18,7 +18,7 @@ Option Explicit Option Private Module 'Version number -Private Const APPLICATION_VERSION As String = "0.4.2.250426" +Private Const APPLICATION_VERSION As String = "0.6.0.261121" Private Const APPLICATION_NAME As String = "ACLib Declaration Dictionary" Private Const APPLICATION_FULLNAME As String = "Access-CodeLib - Declaration Dictionary" diff --git a/source/modules/modApiDialogSupport.bas b/source/modules/modApiDialogSupport.bas index a1502d2..72de99e 100644 --- a/source/modules/modApiDialogSupport.bas +++ b/source/modules/modApiDialogSupport.bas @@ -4,7 +4,7 @@ Option Explicit Option Private Module Public Const DeclDictAddInName As String = "ACLib Declaration Dictionary" -Public Const DeclDictVersion As String = "0.5.0" +Public Const DeclDictVersion As String = "0.6.0" Private m_DeclarationDict As DeclarationDict diff --git a/source/modules/modSort.bas b/source/modules/modSort.bas index 51e5682..821becc 100644 --- a/source/modules/modSort.bas +++ b/source/modules/modSort.bas @@ -1,5 +1,5 @@ Attribute VB_Name = "modSort" -Option Compare Database +Option Compare Text Option Explicit Public Sub QuickSort(ByRef ArrToSort As Variant, ByVal FirstIndex As Long, ByVal LastIndex As Long) diff --git a/source/reports/InfoReportAPI.bas b/source/reports/InfoReportAPI.report similarity index 100% rename from source/reports/InfoReportAPI.bas rename to source/reports/InfoReportAPI.report diff --git a/source/tables/USysAPI.xml b/source/tables/USysAPI.xml index 9b76913..f3620e4 100644 --- a/source/tables/USysAPI.xml +++ b/source/tables/USysAPI.xml @@ -1,7 +1,7 @@  - RunVcsCheck([OpenDialogToFixLettercase], [DeclDictFilePath]) As Variant + RunVcsCheck([OpenDialogToFixLettercase], [DeclDictFilePath], [IncludeUsedMembers]) As Variant <div><font size=2>Compare lettercase from CurrentVbProject with saved (table/file) dictionary items</font></div> <div><font size=2>&nbsp;</font></div> @@ -12,6 +12,7 @@ <div><font size=2>OpenDialogToFixLettercase - (Boolean) - Open dialog to fix lettercase</font></div> <div><font size=2>DeclDictFilePath - (String) - use alternative dictionary file path</font></div> +<div><font size=2>IncludeUsedMembers - (Boolean) - also add used members to the dictionary (default: False)</font></div> </blockquote> @@ -50,7 +51,7 @@ RunVcsCheckDialog() - <div>Equal to <b>RunVcsCheck(True)</b></div> + <div>Equal to <b>RunVcsCheck(True, , True)</b></div> 3 diff --git a/source/tbldefs/USysAPI.xml b/source/tbldefs/USysAPI.xml index ab8918d..7ab7d81 100644 --- a/source/tbldefs/USysAPI.xml +++ b/source/tbldefs/USysAPI.xml @@ -12,24 +12,24 @@ - - + + + + + + + - - - - - - - - + + + - - + + @@ -37,19 +37,19 @@ - - - - + + + + + - - - + - + + @@ -61,20 +61,20 @@ - - - - + + + + + + - - - - - + - + + + @@ -86,16 +86,16 @@ - - + + + + - - - + - + diff --git a/source/tbldefs/tabWords.xml b/source/tbldefs/tabWords.xml index 505613f..06f2e93 100644 --- a/source/tbldefs/tabWords.xml +++ b/source/tbldefs/tabWords.xml @@ -12,23 +12,23 @@ - - + + + + + + + - - - - - - - - + + + - - + + @@ -36,19 +36,19 @@ - - - - + + + + + - - - + - + + @@ -60,19 +60,19 @@ - - - - + + + + + - - - + - + + @@ -84,17 +84,17 @@ - - + - + + + - - - - + + + diff --git a/source/vcs-agent-docs/forms-reports.md b/source/vcs-agent-docs/forms-reports.md new file mode 100644 index 0000000..a6f0b2d --- /dev/null +++ b/source/vcs-agent-docs/forms-reports.md @@ -0,0 +1,105 @@ +# Form and Report Layout Files + +Covers `.form` and `.report` files (legacy projects use `.bas`) and their companion +`.json`. For the `.cls` code-behind, see `vba-modules.md`. + +## The SaveAsText format + +These files use Access's `SaveAsText` format. It is not VBA, and it is largely +undocumented: + +``` +Version =21 <- Access version marker +VersionRequired =20 +Begin Form <- Form or Report + RecordSelectors = NotDefault + Caption ="My Form Title" + Begin + Begin Label <- A control + Left =1234 + Top =567 + Width =2000 + Height =300 + Name ="lblTitle" + Caption ="Welcome" + End + Begin CommandButton + Name ="cmdOK" + Caption ="OK" + OnClick ="[Event Procedure]" + End + End +End +CodeBehindForm <- VBA section, when layout is not split +Attribute VB_Name = "Form_frmMyForm" +``` + +## What is safe to change + +Property edits are safe wherever you can infer the expected format from +neighboring values: caption text inside quotes, geometry such as `Left`, `Top`, +`Width`, and `Height`, colors, and font sizes. On forms (export format 5.1.0+), +layout-group geometry is rewritten to a 60-twip grid, so a track edit rewrites +sibling cells; do not drop `Left`/`Top`/`Width`/`Height` or `EmptyCell` spacers. +`LayoutCached*` is omitted on export. Guessing at a property whose format you +cannot infer breaks the layout or fails the import, so leave those alone, along +with the `Version` lines at the top. Keep `Begin`/`End` balanced throughout. + +## Adding, removing, and renaming controls + +Structural edits work if you copy rather than compose. The property set Access +expects for a control type is not something to invent, so use an existing +control of the same type in the same file as your template. + +To add a control: + +1. Copy an entire `Begin ` ... `End` block, including any nested + `Begin`/`End` subtree. An attached label lives *inside* its text box, combo + box, or check box, and an option group's buttons live inside the group. +2. Paste it into the intended section's inner `Begin` block. Appending at the + end of the section is the safest placement. +3. Give the new control, and every nested control copied with it, a `Name` that + is unique within the file. +4. Set the geometry. Raise the form `Width` and section `Height` if the new + control extends past them. On a Layout-view form, keep `LayoutGroup`, + `GroupTable`, and `RowStart`/`ColumnEnd` consistent with the row you copied. +5. Set `TabIndex` to a value not already used in that section. `TabIndex`, not + file order, determines tab order. +6. If you kept an event property such as `OnClick ="[Event Procedure]"`, add the + handler to the `.cls` code-behind. Access binds handlers by control name, so + `Private Sub cmdSave_Click()` pairs with `Name ="cmdSave"`. + +To remove a control, delete its whole block including nested children, then +remove its event handlers and any references to it from the `.cls`. + +Renaming means updating every reference to the old name: handler procedure names +and code in the `.cls`, and any key for that control in the companion `.json`. + +## Conditional formatting + +With **Decode conditional formatting to JSON** enabled (export format 5.0.0 and +later), the opaque `ConditionalFormat` and `ConditionalFormat14` hex blocks are +stripped out of each control and stored as readable rules in the companion `.json`, +under `Items.ConditionalFormatting` keyed by control name. Edit the rules there +rather than the hex. + +With the option disabled, the binary blocks stay inline in the layout file. Either +way the add-in rebuilds them on import. + +On import the JSON wins. If a control has a JSON entry, any stale inline block for +that control is stripped before the rebuilt block is injected, which keeps repeated +imports idempotent. A control with an inline block but no JSON entry is left +untouched. + +The binary layout and the exact boundary of what survives a decode/rebuild cycle +are documented in +[docs/access-conditional-format.md](https://github.com/joyfullservice/msaccess-vcs-addin/blob/dev/docs/access-conditional-format.md). + +## Recovering from a bad edit + +If a form or report looks wrong after import, the usual causes are an unbalanced +`Begin`/`End` pair or a mangled property value. Restore the `.form` or `.report` +file from git and redo the change in smaller steps. + +To check a structural edit, ask for a re-export after the merge build. A +`git diff` on the file then shows what Access normalized or dropped. diff --git a/source/vcs-agent-docs/queries.md b/source/vcs-agent-docs/queries.md new file mode 100644 index 0000000..1bc6a5c --- /dev/null +++ b/source/vcs-agent-docs/queries.md @@ -0,0 +1,53 @@ +# Query Source Files + +Each query in `queries/` is exported as two files: a `.sql` holding the statement, +and a `.json` holding everything that SQL cannot express. + +## Editing query logic + +Edit the `.sql`. It is the sole source of truth for the query's SQL text, and +changing it is the normal way to change what a query does. + +```sql +SELECT + CustomerID, + CustomerName, + Email +FROM tblCustomers +WHERE Active = True +ORDER BY CustomerName; +``` + +On import the add-in reads both files, generates a temporary `.qdef` in memory, and +hands it to `LoadFromText`. When the SQL is designer-compatible and the `.json` +carries layout data, the query imports in Design View format with table positions +preserved; otherwise it imports as SQL View. Making the SQL incompatible with the +designer — adding a `UNION` or a subquery, for example — causes the layout data to +be ignored and logs a warning, which is expected rather than an error. + +## The companion `.json` + +| Key | Meaning | +|-----|---------| +| `QueryType` | 0 Select, 16 Crosstab, 32 Delete, 48 Update, 64 Append | +| `Connect` | Connection string for pass-through queries, usually an `env:` reference | +| `QueryProperties` | Non-default query properties from the `LvProp` binary blob | +| `Columns` | Column metadata, sorted alphabetically for deterministic output | +| `DesignLayout` | Table positions and window dimensions; present only for queries last saved in Design View | +| `Description` | Object description from DAO document properties | +| `Hidden` | True when the query is hidden in the Navigation Pane | + +Edit these values directly when you need to change a property the SQL cannot carry. +Keep the file valid JSON. + +Pass-through `Connect` values use `env:` references rather than raw ODBC strings; +see `troubleshooting.md` for how those resolve. + +## Legacy files + +Older projects may still contain `.qdef` or `.bas` query files. Import still +accepts them. On export format 4.1.2 the `.bas` file is the import source; a +paired `.sql` is applied only when **Force import of original SQL for queries** +is enabled. To make `.sql` the source of truth, switch to export format 5.0+ +and run a full export — that writes `.sql` plus `.json` and removes the legacy +files. diff --git a/source/vcs-agent-docs/testing.md b/source/vcs-agent-docs/testing.md new file mode 100644 index 0000000..201e79b --- /dev/null +++ b/source/vcs-agent-docs/testing.md @@ -0,0 +1,110 @@ +# Automated Testing + +The add-in includes a test runner that discovers and executes tests in whatever +database is open. Tests assert with `TestAssert`, a drop-in replacement for +`Debug.Assert`. Nothing in the project needs a compile-time reference to the add-in. + +## Setup + +Run `VCS.InstallTestAssertModule` from the Immediate Window to inject the +`modTestAssert` module. `VCS.MigrateDebugAssert` converts existing `Debug.Assert` +calls in bulk. + +## Writing tests + +A test is a parameterless `Public Sub` in a test module: + +```vba +Option Compare Database +Option Explicit +Option Private Module +'@Folder("Tests") + +Public Sub TestDoubleInput() + TestAssert MyFunction(42) = 84, "MyFunction should double input" + TestAssert MyFunction(0) = 0, "Zero input returns zero" +End Sub +``` + +The second `TestAssert` argument is optional context that identifies which +assertion failed, which matters inside loops and shared helpers. + +A module counts as a test module if it carries `'@Folder("...Tests...")` (in +projects using `@Folder` at all) or its name contains `Test`. Within it, only +parameterless `Public Sub` procedures are registered, and only if the module has a +`TestAssert` call. To exclude a helper, make it `Private` or give it a parameter. + +**Class modules** work the same way and add per-test setup and teardown: every test +method gets a fresh instance, so `Class_Initialize` runs before it and +`Class_Terminate` after. Use parameterless `Public Sub` or `Public Function`. Name +test modules `modTest*` or `clsTest*`, and mark standard ones +`Option Private Module`. + +## Prompts during a run + +A run is unattended: a `MsgBox`, `InputBox`, or modal form in code a test reaches +stalls it until someone clicks. `modTestAssert.TestRunActive` is true for the whole +run, so guard anything that waits for a person: + +```vba +If Not TestRunActive Then MsgBox "Import complete.", vbInformation +``` + +Prefer guarding a prompt whose absence changes nothing; where a prompt decides +something, branch to the answer an unattended run should get. A `modTestAssert` +installed before this feature will not have the flag. + +## Running tests + +Run `?VCS.RunTests` from the Immediate Window, or use **Tools > Run Tests** on the +ribbon. After a completed run the runner can re-run only the failures. + +`RunTests` takes an optional `ParamArray` of filters. Each argument resolves in +priority order: exact module name, then suite or `@Folder` value (matching the full +path or its final segment, so `"SQL"` matches `"Tests.SQL"`), then procedure name or +full `Module.Procedure` key, then tag. Prefix an argument with `-` to exclude it. +Inclusions combine with OR, exclusions with AND, and a list containing only +exclusions starts from all tests. + +```vba +?VCS.RunTests("-slow") ' Everything except slow-tagged tests +?VCS.RunTests("Reporting", "-slow") ' The Reporting suite, skipping slow tests +?VCS.RunTests("TestInvoiceTotal") ' One specific procedure +``` + +`RunTests` returns a JSON summary with per-test status, assertion detail, and tags. + +## Tagging + +`'@Tag("name")` annotations categorize tests and are case-insensitive. A +module-level tag sits in the first ~30 lines, before any procedure, and applies to +every test in the module. A procedure-level tag sits at the very top of the +procedure body, before any executable line including `Dim`. The two sets merge. + +## Global suite hooks + +`modTestAssert` may define two optional once-per-run hooks: + +```vba +Public Sub GlobalTestSetup() ' Before the first test, when at least one is selected +Public Sub GlobalTestTeardown() ' After all tests; the results JSON already exists +``` + +`VCS.InstallTestAssertModule` writes empty stubs with inline guidance; if absent +the runner skips them silently. They do not run when no tests are discovered or a +filter matches nothing. An error inside a hook is non-fatal — it goes to the +console, the run continues, and teardown still executes. Per-test +`Class_Initialize` and `Class_Terminate` nest inside these hooks unchanged. + +## Where results land + +| File | Contents | +|------|----------| +| `logs/TestResults_.json` | Per-run results with per-assertion detail | +| `logs/TestRun_.log` | Full console output including timing | +| `test-results/test-state.json` | Merged current state; a partial run updates only the tests it executed and flags the rest `stale` | +| `test-results/test-results.xml` | JUnit XML projection of the state file | +| `test-results/test-results.html` | Self-contained HTML dashboard | + +Both folders are gitignored, so search tools will not find them. See +`troubleshooting.md` for how to list and read them. diff --git a/source/vcs-agent-docs/troubleshooting.md b/source/vcs-agent-docs/troubleshooting.md new file mode 100644 index 0000000..b4103c2 --- /dev/null +++ b/source/vcs-agent-docs/troubleshooting.md @@ -0,0 +1,94 @@ +# Troubleshooting and Logs + +## Reading the logs + +Every operation writes a timestamped log to the `logs/` subfolder. Check the most +recent one first; it carries the detailed output, timing, and error messages. + +| Pattern | Operation | +|---------|-----------| +| `Export_.log` | Export | +| `Build_.log` | Full build | +| `Merge_.log` | Merge build **and** single-object import | +| `TestRun_.log` | Test run console output | + +A single-object import that seems to have produced no log wrote a `Merge_*.log`. + +**`logs/` and `test-results/` are gitignored**, so tools that respect `.gitignore` +— glob, grep, and semantic search — will silently skip them. Use the shell: + +```powershell +Get-ChildItem -Path "logs" | Sort-Object LastWriteTime -Descending | Select-Object -First 3 +Get-ChildItem -Path "test-results" +``` + +## Import fails with no clear error + +Almost always the encoding changed. Confirm the file still begins with the bytes +`EF BB BF` and re-save it as UTF-8 with BOM. + +## Import fails or objects are corrupted after an edit + +Check the line endings. The file needs CRLF (`0D 0A`), not bare LF. Restore it from +git or re-save with CRLF. + +## Unresolved Git conflict markers + +After a `git merge`, `git stash pop`, or branch switch, a source file may still +contain lines starting with `<<<<<<<` or `>>>>>>>`. The add-in skips that file and +logs: + +`Unresolved Git conflict markers in '' (line N). Resolve the conflict in this +file, then merge again.` + +Open the named file, resolve every conflict section, remove the marker lines, save, +and run merge again. + +## "Object not found" after import + +The `Attribute VB_Name` inside the file no longer matches the filename, usually +because the file was renamed without updating the name stored in it. Make them +agree, without the extension. + +## VBA compile error after import + +Typical causes are a syntax error introduced by an edit, a missing declaration, or +a reference to something that does not exist. + +The compile tools available over MCP report only success or failure — never the +failing module or line. When `vcs_compile_vba` returns `success: false`, or +`vcs_check_vba_compiled` returns `compiled: false`: + +1. Stop. Do not edit more source files or guess at a fix. +2. Ask the user to open the database in Access, open the VBA editor, and choose + **Debug > Compile**. Access jumps to the first error. +3. Ask them to paste the few lines around it. The snippet is usually enough; the + error text is optional. +4. Propose a targeted fix, then re-import and re-compile. + +Working in Access directly, the highlighted line after **Debug > Compile** tells +you the same thing. + +## XML parse error + +Invalid syntax such as an unclosed tag, or an unescaped special character. Validate +the structure and check how special characters are encoded. + +## Build prompts for SQL authentication + +Linked tables and pass-through queries store `env:conn_*` references rather than raw +ODBC strings, in `tbldefs/*.json`, the `Connect` value in `queries/*.json`, and +`db-connection.json`. At build time the add-in resolves each reference against the +`.env` file at this folder's root, which is per-developer and gitignored. + +A prompt means the key is missing from the resolved configuration or the server is +unreachable. Search the build log for `Connection key not found in .env file:`. + +`db-connection.json` only **primes** Access's ODBC cache during import, running one +temporary query per connection so later linked-table imports reuse the cached +credentials. It stores `env:` keys, not connection strings, so do not treat it as a +registry of connections. + +Per-environment layering through an `APP_ENV` selector is supported and documented +in the +[Connections wiki page](https://github.com/joyfullservice/msaccess-vcs-addin/wiki/Connections). diff --git a/source/vcs-agent-docs/vba-modules.md b/source/vcs-agent-docs/vba-modules.md new file mode 100644 index 0000000..3da8b3d --- /dev/null +++ b/source/vcs-agent-docs/vba-modules.md @@ -0,0 +1,101 @@ +# VBA Module Source Files + +Covers `.bas` and `.cls` files in `modules/`, and the `.cls` code-behind files in +`forms/` and `reports/`. + +## Standard modules (`.bas`) + +``` +Attribute VB_Name = "ModuleName" <- Required: must match the filename +'--------------------------------------------------------------------------------------- +' Module : ModuleName <- Optional comment header +' Purpose : Description here +'--------------------------------------------------------------------------------------- +Option Compare Database <- Optional +Option Explicit <- Optional + +Public Sub MySub() + ' Code starts after any Option statements +End Sub +``` + +Add and edit procedures, functions, and declarations freely. Leave the +`Attribute VB_Name` line alone; it must equal the filename without its extension. + +`Option` statements are not required. Some projects omit them entirely, so match +whatever the surrounding modules do rather than adding them. + +## Class modules (`.cls`) + +``` +VERSION 1.0 CLASS <- Required header block +BEGIN + MultiUse = -1 'True +END +Attribute VB_Name = "ClassName" <- Required: must match the filename +Attribute VB_GlobalNameSpace = False <- Required (legacy, but must be present) +Attribute VB_Creatable = False +Attribute VB_PredeclaredId = False <- True gives the class a default instance +Attribute VB_Exposed = False <- True exposes it to other projects +Option Compare Database <- Optional +Option Explicit <- Optional + +Private m_Value As String + +Public Property Get Value() As String +Attribute Value.VB_Description = "Returns the value" <- Member attribute + Value = m_Value +End Property +``` + +Edit the code and comment headers. Leave the `VERSION` block and the module-level +`Attribute VB_*` lines exactly as they are. + +## Member attributes + +Attributes can also appear **inside** procedures and properties, carrying metadata +that the VBA editor hides but the Object Browser displays. They go on the line +immediately after the `Sub`, `Function`, or `Property` declaration: + +```vba +Public Function GetItem(Index As Long) As Variant +Attribute GetItem.VB_Description = "Returns item at specified index" +Attribute GetItem.VB_UserMemId = 0 + GetItem = m_Items(Index) +End Function +``` + +| Attribute | Effect | +|-----------|--------| +| `Attribute [Member].VB_Description = "text"` | Description shown in the Object Browser | +| `Attribute [Member].VB_UserMemId = 0` | Makes this the class's default member | +| `Attribute [Member].VB_UserMemId = -4` | Returns an enumerator, enabling `For Each` | + +Reword the description text if it is wrong. Do not change the attribute syntax or +the member name it refers to; the name must match the procedure it sits under. + +## Form and report code-behind + +When the **Split Layout from VBA** option is on, a form's or report's code lives in +its own `.cls` beside the layout file: + +``` +VERSION 1.0 CLASS +BEGIN + MultiUse = -1 'True +END +Attribute VB_Name = "Form_frmMyForm" <- Must be "Form_" (or "Report_") + object name +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = True +Attribute VB_PredeclaredId = True +Attribute VB_Exposed = False +Option Compare Database + +Private Sub Form_Load() + ' Event handler code +End Sub +``` + +Edit event handlers and procedures here as you would in any class module. When the +option is off, the code is instead inside the `.form` or `.report` file under a +`CodeBehindForm` line. diff --git a/source/vcs-options.json b/source/vcs-options.json index c55c9fc..1c6c9cb 100644 --- a/source/vcs-options.json +++ b/source/vcs-options.json @@ -1,15 +1,25 @@ { "Info": { - "AddinVersion": "4.1.2", + "AddinVersion": "5.1.0", "AccessVersion": "16.0 64-bit" }, "Options": { "ExportFolder": "\\source", - "ShowDebug": false, "UseFastSave": true, - "UseMergeBuild": false, - "UseGitIntegration": false, + "SplitLayoutFromVBA": true, + "ExportFormatVersion": "5.1.0", + "RunBeforeExport": "", + "RunAfterExport": "", + "SanitizeLevel": 2, + "SanitizeColors": 1, + "SaveQuerySQL": true, + "FormatSQL": true, + "UseDeterministicQueryExport": true, + "SaveTableSQL": true, "SavePrintVars": false, + "DecodeConditionalFormatting": true, + "ExtractThemeFiles": false, + "UseEnvForConnections": 0, "ExportPrintSettings": { "Orientation": true, "PaperSize": true, @@ -32,15 +42,19 @@ "PaperWidth": false, "TTOption": false }, - "SaveQuerySQL": true, - "FormatSQL": true, + "ExportLayoutSvg": false, + "LayoutSvgImageEmbed": "Small", + "LayoutSvgScaleMode": "Universal", + "ExportAfterMerge": false, "ForceImportOriginalQuerySQL": false, - "SaveTableSQL": true, - "SplitLayoutFromVBA": true, - "StripPublishOption": true, - "SanitizeColors": 1, - "SanitizeLevel": 2, - "ExtractThemeFiles": false, + "UseMergeBuild": false, + "MergeTableData": true, + "SkipReopenBeforeMerge": false, + "RunBeforeBuild": "", + "RunAfterBuild": "", + "RunBeforeMerge": "", + "RunAfterMerge": "", + "ValidateAfterBuild": "", "TablesToExportData": { "USysAPI": { "Format": "XML Format" @@ -54,16 +68,26 @@ }, "SchemaExports": { }, - "RunBeforeExport": "", - "RunAfterExport": "", - "RunBeforeBuild": "", - "RunAfterBuild": "", - "RunBeforeMerge": "", - "RunAfterMerge": "", - "ShowVCSLegacy": true, + "McpAllowImport": true, + "McpAllowCallVBA": true, + "McpAllowExecuteSQL": false, + "McpAllowRunVBA": true, + "DefaultTestFilter": "", + "ShowDebug": false, + "BreakOnError": false, + "MaxLogFiles": 20, + "StripPublishOption": true, + "PreserveRubberDuckID": false, + "SaveAllDocumentProperties": false, + "SaveLinkedTableDef": false, "HashAlgorithm": "SHA256", "UseShortHash": true, - "BreakOnError": false, - "PreserveRubberDuckID": false + "UseGitIntegration": false, + "ShowVCSLegacy": true, + "UseWebTestRunner": true, + "ExportTestResultsJUnit": true, + "ExportTestResultsHtml": true, + "ExportPerfJson": false, + "McpProgressIntervalMs": 500 } }