office-gobmx/include/editeng/hyphenzoneitem.hxx
László Németh 6e8819f29b tdf#132599 cui offapi sw xmloff: add hyphenation-keep-type
Support XSL attribute "column" and CSS 4 attribute "spread",
stored in loext:hyphenation-keep-type, to give better control
over hyphenation-keep. E.g. spread: both parts of a hyphenated
word shall lie within a single spread, i.e. when the next page
is not visible at the same time (e.g. the next page is not a
right page of a book).

– css::style::ParaHyphenationKeep is a boolean property now,
  importing hyphenation-keep = "page" as true.

– type of ParaHyphenationKeep, including the new non-ODF types
  is stored in the new ParagraphProperties::ParaHyphenationKeepType.

– default value of ParaHyphenationKeepType is COLUMN for
  interoperability.

– Add checkboxes to Text Flow -> Hyphenation Across in
  paragraph dialog:

  * Column (previously: Hyphenate across column and page)
  * Page
  * Spread

  – enabling/disabling them follows XSL/CSS 4/loext, i.e.
    possible combinations:

  * No Hyphenation across
    (hyphenation-keep = "page" and loext:hyphenation-keep-type = "column")

  * Hyphenation across [x] Column
    (hyphenation-keep = "page" and loext:hyphenation-keep-type = "page")

  * Hyphenation across [x] Column [x] Page
    (hyphenation-keep = "page" and loext:hyphenation-keep-type = "spread")

  * Hyphenation across [x] Column [x] Page [x] Spread
    (hyphenation-keep = "auto")

– Add ODF import/export

– Update DOCX import

– Add ODF unit tests

Note: recent implementation depends on widow settings: disabling widow
handling allows hyphenation across columns and pages not only in table
cells.

Note: RTF import-only, but not used bPageEnd has been renamed to bKeep.
Depending on the RTF test results, likely it will need to disable
the layout change, e.g. GetKeepType()=ParagraphHyphenationKeepType::AUTO,
if PageEnd uses obsolete hyphenation rule, i.e. shifting only the
hyphenated word to the next page, not the full line.

More information:

– COLUMN (standard XSL value, defined in
  https://www.w3.org/TR/2001/REC-xsl-20011015/slice7.html#hyphenation-keep)

– SPREAD and ALWAYS (CSS 4 values of hyphenate-limit-last,
  equivalent of hyphenation-keep, defined in
  https://www.w3.org/TR/css-text-4/#hyphenate-line-limits).

Follow-up to commit 9574a62add
"tdf#132599 cui offapi sw xmloff: implement hyphenate-keep" and
commit c8ee0e8f58
"tdf160518 DOCX: import hyphenation-keep to fix layout".

Change-Id: I3ac6d9e86d0ed1646f105de8607c0e8ebc534eaa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165954
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
2024-04-11 10:20:41 +02:00

100 lines
4.2 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_EDITENG_HYPHENZONEITEM_HXX
#define INCLUDED_EDITENG_HYPHENZONEITEM_HXX
#include <svl/poolitem.hxx>
#include <editeng/editengdllapi.h>
// class SvxHyphenZoneItem -----------------------------------------------
/* [Description]
This item describes a hyphenation attribute (automatic?, number of
characters at the end of the line and start).
*/
class EDITENG_DLLPUBLIC SvxHyphenZoneItem final : public SfxPoolItem
{
bool bHyphen : 1;
bool bKeep : 1; // avoid hyphenation across page etc., see ParagraphHyphenationKeep
bool bNoCapsHyphenation : 1;
bool bNoLastWordHyphenation : 1;
sal_uInt8 nMinLead;
sal_uInt8 nMinTrail;
sal_uInt8 nMaxHyphens; // max. consecutive lines with hyphenation
sal_uInt8 nMinWordLength; // hyphenate only words with at least nMinWordLength characters
sal_uInt16 nTextHyphenZone; // don't force hyphenation at line end, allow this extra white space
sal_uInt8 nKeepType; // avoid hyphenation across page etc., see ParagraphHyphenationKeep
sal_uInt8 nCompoundMinLead; // min. characters between compound word boundary and hyphenation
public:
static SfxPoolItem* CreateDefault();
SvxHyphenZoneItem( const bool bHyph /*= false*/,
const sal_uInt16 nId );
// "pure virtual Methods" from SfxPoolItem
virtual bool operator==( const SfxPoolItem& ) const override;
virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
virtual bool GetPresentation( SfxItemPresentation ePres,
MapUnit eCoreMetric,
MapUnit ePresMetric,
OUString &rText, const IntlWrapper& ) const override;
virtual SvxHyphenZoneItem* Clone( SfxItemPool *pPool = nullptr ) const override;
void SetHyphen( const bool bNew ) { bHyphen = bNew; }
bool IsHyphen() const { return bHyphen; }
void SetKeep( const bool bNew ) { bKeep = bNew; }
bool IsKeep() const { return bKeep; }
void SetNoCapsHyphenation( const bool bNew ) { bNoCapsHyphenation = bNew; }
bool IsNoCapsHyphenation() const { return bNoCapsHyphenation; }
void SetNoLastWordHyphenation( const bool bNew ) { bNoLastWordHyphenation = bNew; }
bool IsNoLastWordHyphenation() const { return bNoLastWordHyphenation; }
sal_uInt8 &GetMinLead() { return nMinLead; }
sal_uInt8 GetMinLead() const { return nMinLead; }
sal_uInt8 &GetMinTrail() { return nMinTrail; }
sal_uInt8 GetMinTrail() const { return nMinTrail; }
sal_uInt8 &GetCompoundMinLead() { return nCompoundMinLead; }
sal_uInt8 GetCompoundMinLead() const { return nCompoundMinLead; }
sal_uInt8 &GetMaxHyphens() { return nMaxHyphens; }
sal_uInt8 GetMaxHyphens() const { return nMaxHyphens; }
sal_uInt8 &GetMinWordLength() { return nMinWordLength; }
sal_uInt8 GetMinWordLength() const { return nMinWordLength; }
sal_uInt16 &GetTextHyphenZone() { return nTextHyphenZone; }
sal_uInt16 GetTextHyphenZone() const { return nTextHyphenZone; }
sal_uInt8 &GetKeepType() { return nKeepType; }
sal_uInt8 GetKeepType() const { return nKeepType; }
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */