5.2 KiB
Ollama/Gemma Task: QOffice Next Iteration
You are Gemma running through Ollama. Work on the local repository:
G:\Repos\QOffice
Project objective: QOffice is a cross-platform Russian-language office suite intended to move toward Microsoft Office-like functionality. It contains separate applications: QWord, QExcell, QPowerPoint, and QOutlook. Microsoft Office file compatibility is a core requirement.
Current verified repository state:
git status --short --branchreturned## main...origin/main.- Latest commit before this task:
5487d04 Add QPowerPoint slide size support. - QWord already has DOCX import/export, page setup controls, and a Microsoft Word-like ribbon.
- QWord does not yet implement DOCX header/footer support.
Iteration Goal
Implement QWord support for Microsoft Word / DOCX headers and footers.
The feature must be real DOCX compatibility work. Do not implement this only as internal JSON state. Import and export must read and write actual DOCX header/footer parts or clearly explain why that is impossible after inspecting the local docx package API.
Files To Inspect First
First check for local project instructions:
rg --files -g AGENTS.md
Then inspect these files before editing:
src/types.tssrc/data/sampleData.tssrc/App.tsxsrc/io/wordOffice.tssrc/io/wordOffice.test.tssrc/io/wordOfficeImport.test.tssrc/features/qword/QWord.tsxsrc/features/qword/QWord.test.tsx
Verified Starting Points
src/types.ts:WordDocumentcurrently hasid,title,updatedAt,html, and optionalpageSetup.src/io/wordOffice.ts:importDocxFileimports DOCX throughmammoth,styledDocxHtmlFromArrayBuffer, anddocxPageSetupFromArrayBuffer.src/io/wordOffice.ts:exportDocxBlobcurrently accepts onlypageSetupin its options object.src/io/wordOffice.ts:lastDocxSectionPropertiesalready finds the finalw:sectPr.src/features/qword/QWord.tsx:openDocxapplies importedtitle,html, andpageSetup.src/features/qword/QWord.tsx:saveDocxpasses onlypageSetupintoexportDocxBlob.- QWord's
layoutribbon tab already contains page setup controls.
Implementation Requirements
-
Data model:
Add optional QWord document fields. Preferred names:
headerHtml?: string; footerHtml?: string;Existing saved documents without these fields must remain valid.
-
DOCX import:
- Read
word/document.xml. - Find the final applicable
w:sectPr. - Read
w:headerReferenceandw:footerReference. - Resolve their relationship ids through
word/_rels/document.xml.rels. - Read the corresponding
word/header*.xmlandword/footer*.xmlparts. - For this first iteration, support the
defaultreference type. - Do not break documents that also contain
firstorevenreferences; those can be ignored for now. - Convert header/footer content into HTML using the existing
wordOffice.tshelper patterns. Preserve at least paragraphs and basic inline text styling.
- Read
-
DOCX export:
- Extend
exportDocxBloboptions to acceptheaderHtmlandfooterHtml. - Use the local
docxpackage API to create real DOCX header/footer parts if available. - Reuse the existing HTML-to-DOCX block pipeline where practical.
- Preserve existing
pageSetupbehavior. - Generated DOCX must contain real header/footer parts and relationships.
- Extend
-
QWord UI:
- Add Russian-language controls for header and footer.
- Preferred location: QWord
layoutribbon tab near page setup. - Do not add a right sidebar.
- Use clear Russian labels, for example:
Верхний колонтитулНижний колонтитул
- Editing these fields must call
onChangewith updateddocument.headerHtmlanddocument.footerHtml. openDocxmust apply imported header/footer fields.saveDocxmust pass header/footer fields toexportDocxBlob.
-
Tests:
Add focused regression tests:
- Import DOCX with
headerReferenceandfooterReference; assert importedheaderHtmlandfooterHtml. - Export DOCX with header/footer; assert header/footer parts and relationships exist.
- Roundtrip export -> import; assert header/footer values survive.
- QWord UI test: changing header/footer controls calls
onChangewithheaderHtmlandfooterHtml.
- Import DOCX with
Verification Commands
Run the narrow test set first:
npx vitest run src\io\wordOffice.test.ts src\io\wordOfficeImport.test.ts src\features\qword\QWord.test.tsx
If the narrow tests pass, run:
npm run build
npm test
npm audit --audit-level=high
Constraints
- Do not touch unrelated files.
- Do not revert user changes.
- Do not run destructive git commands.
- Do not add dependencies unless necessary.
- Follow the existing project patterns.
- If you are only an LLM without filesystem access, return a unified diff patch and verification commands.
- If you are running inside an agent with filesystem access, edit the files directly but do not commit or push.
Final Response Required
Report:
- changed files;
- tests and command results;
- exactly how DOCX import/export was implemented;
- any remaining risks or unverified behavior.