Files
odfstudio/sw/source/core/draw
Julien Nabet 05f7513a5f Related tdf#164685: Cleanup class SfxItemSetFixed (sw remnants part1)
Python script used:
import re
from pathlib import Path

def transform(content: str) -> str:
    i = 0
    out = []
    n = len(content)

    while i < n:
        if content.startswith("SfxItemSetFixed<", i):
            i += len("SfxItemSetFixed<")

            # --- parse template <...> avec équilibrage ---
            depth = 1
            start = i
            while i < n and depth > 0:
                if content[i] == '<':
                    depth += 1
                elif content[i] == '>':
                    depth -= 1
                i += 1

            template = content[start:i-1]

            # --- skip espaces ---
            while i < n and content[i].isspace():
                i += 1

            # --- variable ---
            m = re.match(r'[A-Za-z_]\w*', content[i:])
            if not m:
                out.append("SfxItemSetFixed<" + template + ">")
                continue

            var = m.group(0)
            i += len(var)

            # --- skip espaces ---
            while i < n and content[i].isspace():
                i += 1

            # --- arguments (...) ---
            if i >= n or content[i] != '(':
                out.append("SfxItemSetFixed<" + template + ">" + var)
                continue

            i += 1
            depth = 1
            start = i
            while i < n and depth > 0:
                if content[i] == '(':
                    depth += 1
                elif content[i] == ')':
                    depth -= 1
                i += 1

            args = content[start:i-1]

            # --- remplacement ---
            out.append(f"SfxItemSet {var}(SfxItemSet::makeFixedSfxItemSet<{template}>({args}))")

        else:
            out.append(content[i])
            i += 1

    return ''.join(out)


def process_file(path: Path):
    text = path.read_text(encoding="utf-8")
    new_text = transform(text)

    if new_text != text:
        backup = path.with_suffix(path.suffix + ".bak")
        backup.write_text(text, encoding="utf-8")
        path.write_text(new_text, encoding="utf-8")
        print(f"Updated: {path}")


# --- scan files ---
for ext in ("*.cxx", "*.hxx"):
    for file in Path(".").rglob(ext):
        process_file(file)


Change-Id: I6b90d403777422d0d7aaa7b49bc117e653441eb7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203935
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
2026-04-19 21:35:17 +02:00
..