Repository: owncloud/ocis
Pull request #11177 (2025-03-28 13:33:11)

[full-ci] backport pdf form fix
<!--
Thanks for submitting a change to ownCloud!

This is the bug tracker for the oCIS component. Find other components at https://github.com/owncloud/core/blob/master/.github/CONTRIBUTING.md#guidelines

For fixing potential security issues please see https://owncloud.org/security/

To make it possible for us to get your change reviewed and merged please carefully fill out the requested information below.

Please note that any kind of change needs first be submitted to the master branch which holds the next version of oCIS.

Please set the following labels:

- Set label "Status:Needs-Review" for review or "Status:In-Progress" if the PR still has open tasks.
- Assignment: assign to self
- Reviewers: pick at least one
-->

## Description
<!--- Describe your changes in detail -->

## Related Issue
<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->
- Fixes <issue_link>

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->
- test environment:
- test case 1:
- test case 2:
- ...

## Screenshots (if appropriate):

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Technical debt
- [ ] Tests only (no source changes)

## Checklist:
<!-- Tick the checkboxes when done. -->
<!-- Raise documentation ticket in owncloud.github.io/ -->
- [ ] Code changes
- [ ] Unit tests added
- [ ] Acceptance tests added
- [ ] Documentation ticket raised: <link> 



Patch:
diff --git a/changelog/7.1.2_2025-03-28/fix-pdf-form.md b/changelog/7.1.2_2025-03-28/fix-pdf-form.md
new file mode 100644
index 00000000000..61ab7453c32
--- /dev/null
+++ b/changelog/7.1.2_2025-03-28/fix-pdf-form.md
@@ -0,0 +1,7 @@
+Bugfix: Fix pdf form creation
+
+Fix pdf form creation for Onlyoffice.
+Adjust the file extension for Form to be PDF instead of DOCXF
+
+https://github.com/owncloud/ocis/pull/11163
+https://github.com/owncloud/ocis/issues/11164
diff --git a/deployments/examples/ocis_full/config/ocis/app-registry.yaml b/deployments/examples/ocis_full/config/ocis/app-registry.yaml
index b7cf0decf9a..bdda5382b77 100644
--- a/deployments/examples/ocis_full/config/ocis/app-registry.yaml
+++ b/deployments/examples/ocis_full/config/ocis/app-registry.yaml
@@ -1,12 +1,5 @@
 app_registry:
   mimetypes:
-  - mime_type: application/pdf
-    extension: pdf
-    name: PDF
-    description: PDF document
-    icon: ''
-    default_app: ''
-    allow_creation: false
   - mime_type: application/vnd.oasis.opendocument.text
     extension: odt
     name: OpenDocument
@@ -41,7 +34,7 @@ app_registry:
     description: Form Document
     icon: ''
     default_app: OnlyOffice
-    allow_creation: true
+    allow_creation: false
   - mime_type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
     extension: xlsx
     name: Microsoft Excel
@@ -56,6 +49,13 @@ app_registry:
     icon: ''
     default_app: OnlyOffice
     allow_creation: true
+  - mime_type: application/pdf
+    extension: pdf
+    name: PDF form
+    description: PDF form document
+    icon: ''
+    default_app: OnlyOffice
+    allow_creation: true
   - mime_type: application/vnd.jupyter
     extension: ipynb
     name: Jupyter Notebook
diff --git a/deployments/examples/ocis_full/config/onlyoffice/local.json b/deployments/examples/ocis_full/config/onlyoffice/local.json
index 0db571fad42..21ded73c0cd 100755
--- a/deployments/examples/ocis_full/config/onlyoffice/local.json
+++ b/deployments/examples/ocis_full/config/onlyoffice/local.json
@@ -67,5 +67,4 @@
 			]
 		}
 	}
-
 }
diff --git a/services/app-registry/pkg/config/defaults/defaultconfig.go b/services/app-registry/pkg/config/defaults/defaultconfig.go
index 1c51f77c7fe..db87e974e1c 100644
--- a/services/app-registry/pkg/config/defaults/defaultconfig.go
+++ b/services/app-registry/pkg/config/defaults/defaultconfig.go
@@ -37,12 +37,6 @@ func DefaultConfig() *config.Config {
 
 func defaultMimeTypeConfig() []config.MimeTypeConfig {
 	return []config.MimeTypeConfig{
-		{
-			MimeType:    "application/pdf",
-			Extension:   "pdf",
-			Name:        "PDF",
-			Description: "PDF document",
-		},
 		{
 			MimeType:      "application/vnd.oasis.opendocument.text",
 			Extension:     "odt",
@@ -72,11 +66,10 @@ func defaultMimeTypeConfig() []config.MimeTypeConfig {
 			AllowCreation: true,
 		},
 		{
-			MimeType:      "application/vnd.openxmlformats-officedocument.wordprocessingml.form",
-			Extension:     "docxf",
-			Name:          "Form Document",
-			Description:   "Form Document",
-			AllowCreation: true,
+			MimeType:    "application/vnd.openxmlformats-officedocument.wordprocessingml.form",
+			Extension:   "docxf",
+			Name:        "Form Document",
+			Description: "Form Document",
 		},
 		{
 			MimeType:      "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
@@ -92,6 +85,13 @@ func defaultMimeTypeConfig() []config.MimeTypeConfig {
 			Description:   "Microsoft PowerPoint document",
 			AllowCreation: true,
 		},
+		{
+			MimeType:      "application/pdf",
+			Extension:     "pdf",
+			Name:          "PDF form",
+			Description:   "PDF form document",
+			AllowCreation: true,
+		},
 		{
 			MimeType:    "application/vnd.jupyter",
 			Extension:   "ipynb",
diff --git a/services/collaboration/pkg/connector/fileconnector.go b/services/collaboration/pkg/connector/fileconnector.go
index 21522e53b51..67803fb0554 100644
--- a/services/collaboration/pkg/connector/fileconnector.go
+++ b/services/collaboration/pkg/connector/fileconnector.go
@@ -1243,9 +1243,20 @@ func (f *FileConnector) CheckFileInfo(ctx context.Context) (*ConnectorResponse,
 		}
 	}
 	// fileinfo map
+	var size interface{}
+	size = int64(statRes.GetInfo().GetSize())
+	// OnlyOffice requires a 0 size of files for "pdf" files, for extensions "docx", "xlsx", "pptx" it is optional
+	// For other extensions like "ods", "odt", "odp" the 0 size should be omitted
+	if strings.ToLower(f.cfg.App.Product) == "onlyoffice" && statRes.GetInfo().GetSize() == 0 {
+		ext := strings.ToLower(path.Ext(statRes.GetInfo().GetPath()))
+		if ext != ".pdf" {
+			size = nil
+		}
+	}
+
 	infoMap := map[string]interface{}{
 		fileinfo.KeyOwnerID:           hexEncodedOwnerId,
-		fileinfo.KeySize:              int64(statRes.GetInfo().GetSize()),
+		fileinfo.KeySize:              size,
 		fileinfo.KeyVersion:           getVersion(statRes.GetInfo().GetMtime()),
 		fileinfo.KeyBaseFileName:      path.Base(statRes.GetInfo().GetPath()),
 		fileinfo.KeyBreadcrumbDocName: path.Base(statRes.GetInfo().GetPath()),
diff --git a/services/collaboration/pkg/connector/fileinfo/onlyoffice.go b/services/collaboration/pkg/connector/fileinfo/onlyoffice.go
index 4a6535a46dd..02a071ca49c 100644
--- a/services/collaboration/pkg/connector/fileinfo/onlyoffice.go
+++ b/services/collaboration/pkg/connector/fileinfo/onlyoffice.go
@@ -1,5 +1,9 @@
 package fileinfo
 
+import (
+	"github.com/owncloud/ocis/v2/ocis-pkg/conversions"
+)
+
 // OnlyOffice fileInfo properties
 //
 // OnlyOffice WOPI check file info specification:
@@ -13,6 +17,8 @@ type OnlyOffice struct {
 	BaseFileName string `json:"BaseFileName,omitempty"`
 	// copied from MS WOPI
 	Version string `json:"Version,omitempty"`
+	// The size of the file in bytes, expressed as a long, a 64-bit signed integer.
+	Size *int64 `json:"Size,omitempty"`
 
 	//
 	// Breadcrumb properties
@@ -137,6 +143,10 @@ func (oinfo *OnlyOffice) SetProperties(props map[string]interface{}) {
 			oinfo.BaseFileName = value.(string)
 		case KeyVersion:
 			oinfo.Version = value.(string)
+		case KeySize:
+			if value != nil {
+				oinfo.Size = conversions.ToPointer(value.(int64))
+			}
 
 		case KeyBreadcrumbBrandName:
 			oinfo.BreadcrumbBrandName = value.(string)


Test patch:
diff --git a/services/collaboration/pkg/connector/fileconnector_test.go b/services/collaboration/pkg/connector/fileconnector_test.go
index 73e68d0a0b7..669e92df556 100644
--- a/services/collaboration/pkg/connector/fileconnector_test.go
+++ b/services/collaboration/pkg/connector/fileconnector_test.go
@@ -22,6 +22,7 @@ import (
 	cs3mocks "github.com/cs3org/reva/v2/tests/cs3mocks/mocks"
 	. "github.com/onsi/ginkgo/v2"
 	. "github.com/onsi/gomega"
+	"github.com/owncloud/ocis/v2/ocis-pkg/conversions"
 	"github.com/owncloud/ocis/v2/ocis-pkg/shared"
 	collabmocks "github.com/owncloud/ocis/v2/services/collaboration/mocks"
 	"github.com/owncloud/ocis/v2/services/collaboration/pkg/config"
@@ -1876,6 +1877,7 @@ var _ = Describe("FileConnector", func() {
 
 			expectedFileInfo := &fileinfo.OnlyOffice{
 				Version:                 "v162738490",
+				Size:                    conversions.ToPointer(int64(998877)),
 				BaseFileName:            "test.txt",
 				BreadcrumbDocName:       "test.txt",
 				BreadcrumbFolderName:    "/path/to",