diff options
Diffstat (limited to 'editeng/inc')
-rw-r--r-- | editeng/inc/AccessibleStringWrap.hxx | 50 | ||||
-rw-r--r-- | editeng/inc/editattr.hxx | 406 | ||||
-rw-r--r-- | editeng/inc/editdoc.hxx | 832 | ||||
-rw-r--r-- | editeng/inc/editeng.hxx | 28 | ||||
-rw-r--r-- | editeng/inc/editxml.hxx | 33 | ||||
-rw-r--r-- | editeng/inc/edtspell.hxx | 144 | ||||
-rw-r--r-- | editeng/inc/eerdll2.hxx | 67 | ||||
-rw-r--r-- | editeng/inc/pch/precompiled_editeng.cxx | 12 | ||||
-rw-r--r-- | editeng/inc/pch/precompiled_editeng.hxx | 325 | ||||
-rw-r--r-- | editeng/inc/strings.hrc | 44 | ||||
-rw-r--r-- | editeng/inc/unomodel.hxx | 68 | ||||
-rw-r--r-- | editeng/inc/unopracc.hxx | 56 |
12 files changed, 2065 insertions, 0 deletions
diff --git a/editeng/inc/AccessibleStringWrap.hxx b/editeng/inc/AccessibleStringWrap.hxx new file mode 100644 index 000000000..f3888fd67 --- /dev/null +++ b/editeng/inc/AccessibleStringWrap.hxx @@ -0,0 +1,50 @@ +/* -*- 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 . + */ + +#pragma once + +#include <sal/types.h> +#include <rtl/ustring.hxx> + +class OutputDevice; +class SvxFont; +namespace tools { class Rectangle; } +class Point; + + +// AccessibleStringWrap declaration + + +class AccessibleStringWrap +{ +public: + + AccessibleStringWrap( OutputDevice& rDev, SvxFont& rFont, OUString aText ); + + void GetCharacterBounds( sal_Int32 nIndex, tools::Rectangle& rRect ); + sal_Int32 GetIndexAtPoint( const Point& rPoint ); + +private: + + OutputDevice& mrDev; + SvxFont& mrFont; + OUString maText; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/editattr.hxx b/editeng/inc/editattr.hxx new file mode 100644 index 000000000..502a5b084 --- /dev/null +++ b/editeng/inc/editattr.hxx @@ -0,0 +1,406 @@ +/* -*- 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 . + */ + +#pragma once + +#include <editeng/eeitem.hxx> +#include <svl/poolitem.hxx> +#include <optional> +#include <tools/color.hxx> +#include <tools/debug.hxx> + +class SvxFont; +class SvxFontItem; +class SvxWeightItem; +class SvxPostureItem; +class SvxShadowedItem; +class SvxEscapementItem; +class SvxContourItem; +class SvxCrossedOutItem; +class SvxUnderlineItem; +class SvxOverlineItem; +class SvxFontHeightItem; +class SvxCharScaleWidthItem; +class SvxColorItem; +class SvxAutoKernItem; +class SvxKerningItem; +class SvxWordLineModeItem; +class SvxFieldItem; +class SvxLanguageItem; +class SvxEmphasisMarkItem; +class SvxCharReliefItem; +class SfxVoidItem; +class OutputDevice; +class SvxCaseMapItem; +class SfxGrabBagItem; + +#define CH_FEATURE_OLD (sal_uInt8) 0xFF +#define CH_FEATURE u'\x0001' + +// DEF_METRIC: For my pool, the DefMetric should always appear when +// GetMetric (nWhich)! +// => To determine the DefMetric simply use GetMetric(0) +#define DEF_METRIC 0 + + + +// bFeature: Attribute must not expand/shrink, length is always 1 +// bEdge: Attribute will not expand, if you want to expand just on the edge +class EditCharAttrib +{ + const SfxPoolItem* pItem; + + sal_Int32 nStart; + sal_Int32 nEnd; + bool bFeature :1; + bool bEdge :1; + +public: + EditCharAttrib( const SfxPoolItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + virtual ~EditCharAttrib(); + + EditCharAttrib(const EditCharAttrib&) = delete; + EditCharAttrib& operator=(const EditCharAttrib&) = delete; + + void dumpAsXml(xmlTextWriterPtr pWriter) const; + + sal_uInt16 Which() const { return pItem->Which(); } + const SfxPoolItem* GetItem() const { return pItem; } + + sal_Int32& GetStart() { return nStart; } + sal_Int32& GetEnd() { return nEnd; } + + sal_Int32 GetStart() const { return nStart; } + sal_Int32 GetEnd() const { return nEnd; } + + inline sal_Int32 GetLen() const; + + inline void MoveForward( sal_Int32 nDiff ); + inline void MoveBackward( sal_Int32 nDiff ); + + inline void Expand( sal_Int32 nDiff ); + inline void Collaps( sal_Int32 nDiff ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); + + bool IsIn( sal_Int32 nIndex ) const + { return ( ( nStart <= nIndex ) && ( nEnd >= nIndex ) ); } + bool IsInside( sal_Int32 nIndex ) const + { return ( ( nStart < nIndex ) && ( nEnd > nIndex ) ); } + bool IsEmpty() const + { return nStart == nEnd; } + + bool IsFeature() const { return bFeature; } + void SetFeature( bool b) { bFeature = b; } + + bool IsEdge() const { return bEdge; } + void SetEdge( bool b ) { bEdge = b; } +}; + +inline sal_Int32 EditCharAttrib::GetLen() const +{ + DBG_ASSERT( nEnd >= nStart, "EditCharAttrib: nEnd < nStart!" ); + return nEnd-nStart; +} + +inline void EditCharAttrib::MoveForward( sal_Int32 nDiff ) +{ + DBG_ASSERT( SAL_MAX_INT32 - nDiff > nEnd, "EditCharAttrib: MoveForward?!" ); + nStart = nStart + nDiff; + nEnd = nEnd + nDiff; +} + +inline void EditCharAttrib::MoveBackward( sal_Int32 nDiff ) +{ + DBG_ASSERT( (nStart - nDiff) >= 0, "EditCharAttrib: MoveBackward?!" ); + nStart = nStart - nDiff; + nEnd = nEnd - nDiff; +} + +inline void EditCharAttrib::Expand( sal_Int32 nDiff ) +{ + DBG_ASSERT( SAL_MAX_INT32 - nDiff > nEnd, "EditCharAttrib: Expand?!" ); + DBG_ASSERT( !bFeature, "Please do not expand any features!" ); + nEnd = nEnd + nDiff; +} + +inline void EditCharAttrib::Collaps( sal_Int32 nDiff ) +{ + DBG_ASSERT( nEnd - nDiff >= nStart, "EditCharAttrib: Collaps?!" ); + DBG_ASSERT( !bFeature, "Please do not shrink any Features!" ); + nEnd = nEnd - nDiff; +} + + + +class EditCharAttribFont final : public EditCharAttrib +{ +public: + EditCharAttribFont( const SvxFontItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribWeight final : public EditCharAttrib +{ +public: + EditCharAttribWeight( const SvxWeightItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + +class EditCharAttribItalic final : public EditCharAttrib +{ +public: + EditCharAttribItalic( const SvxPostureItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribShadow final : public EditCharAttrib +{ +public: + EditCharAttribShadow( const SvxShadowedItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribEscapement final : public EditCharAttrib +{ +public: + EditCharAttribEscapement( const SvxEscapementItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribOutline final : public EditCharAttrib +{ +public: + EditCharAttribOutline( const SvxContourItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribStrikeout final : public EditCharAttrib +{ +public: + EditCharAttribStrikeout( const SvxCrossedOutItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribCaseMap final : public EditCharAttrib +{ +public: + EditCharAttribCaseMap( const SvxCaseMapItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribUnderline final : public EditCharAttrib +{ +public: + EditCharAttribUnderline( const SvxUnderlineItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribOverline final : public EditCharAttrib +{ +public: + EditCharAttribOverline( const SvxOverlineItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribEmphasisMark final : public EditCharAttrib +{ +public: + EditCharAttribEmphasisMark( const SvxEmphasisMarkItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribRelief final : public EditCharAttrib +{ +public: + EditCharAttribRelief( const SvxCharReliefItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribFontHeight final : public EditCharAttrib +{ +public: + EditCharAttribFontHeight( const SvxFontHeightItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribFontWidth final : public EditCharAttrib +{ +public: + EditCharAttribFontWidth( const SvxCharScaleWidthItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribColor final : public EditCharAttrib +{ +public: + EditCharAttribColor( const SvxColorItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + +class EditCharAttribBackgroundColor final : public EditCharAttrib +{ +public: + EditCharAttribBackgroundColor(const SvxColorItem& rAttr, + sal_Int32 nStart, + sal_Int32 nEnd ); + virtual void SetFont(SvxFont& rFont, OutputDevice* pOutDev) override; +}; + + + +class EditCharAttribLanguage final : public EditCharAttrib +{ +public: + EditCharAttribLanguage( const SvxLanguageItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribTab final : public EditCharAttrib +{ +public: + EditCharAttribTab( const SfxVoidItem& rAttr, sal_Int32 nPos ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribLineBreak final : public EditCharAttrib +{ +public: + EditCharAttribLineBreak( const SfxVoidItem& rAttr, sal_Int32 nPos ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribField final : public EditCharAttrib +{ + OUString aFieldValue; + std::optional<Color> mxTxtColor; + std::optional<Color> mxFldColor; + + EditCharAttribField& operator = ( const EditCharAttribField& rAttr ) = delete; + +public: + EditCharAttribField( const SvxFieldItem& rAttr, sal_Int32 nPos ); + EditCharAttribField( const EditCharAttribField& rAttr ); + virtual ~EditCharAttribField() override; + + bool operator == ( const EditCharAttribField& rAttr ) const; + bool operator != ( const EditCharAttribField& rAttr ) const + { return !(operator == ( rAttr ) ); } + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; + std::optional<Color>& GetTextColor() { return mxTxtColor; } + std::optional<Color>& GetFieldColor() { return mxFldColor; } + + const OUString& GetFieldValue() const { return aFieldValue;} + void SetFieldValue(const OUString& rVal); + + void Reset(); +}; + + + +class EditCharAttribPairKerning final : public EditCharAttrib +{ +public: + EditCharAttribPairKerning( const SvxAutoKernItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribKerning final : public EditCharAttrib +{ +public: + EditCharAttribKerning( const SvxKerningItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + + +class EditCharAttribWordLineMode final : public EditCharAttrib +{ +public: + EditCharAttribWordLineMode( const SvxWordLineModeItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override; +}; + + +class EditCharAttribGrabBag final : public EditCharAttrib +{ +public: + EditCharAttribGrabBag( const SfxGrabBagItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx new file mode 100644 index 000000000..6ce00d05c --- /dev/null +++ b/editeng/inc/editdoc.hxx @@ -0,0 +1,832 @@ +/* -*- 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 . + */ + +#pragma once + +#include "editattr.hxx" +#include "edtspell.hxx" +#include "eerdll2.hxx" +#include <editeng/svxfont.hxx> +#include <svl/itemset.hxx> +#include <svl/style.hxx> +#include <svl/itempool.hxx> +#include <svl/languageoptions.hxx> +#include <tools/lineend.hxx> +#include <o3tl/typed_flags_set.hxx> + +#include <cstddef> +#include <memory> +#include <string_view> +#include <vector> + +class ImpEditEngine; +class SvxTabStop; +enum class TextRotation; + + +#define CHARPOSGROW 16 +#define DEFTAB 720 + +void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent = true, SvtScriptType nScriptType = SvtScriptType::NONE ); +sal_uInt16 GetScriptItemId( sal_uInt16 nItemId, SvtScriptType nScriptType ); +bool IsScriptItemValid( sal_uInt16 nItemId, short nScriptType ); + +EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sal_Int32 nS, sal_Int32 nE ); + +class ContentNode; +class EditDoc; + +struct EPaM +{ + sal_Int32 nPara; + sal_Int32 nIndex; + + EPaM() : nPara(0), nIndex(0) {} + EPaM( sal_Int32 nP, sal_Int32 nI ) : nPara(nP), nIndex(nI) {} + EPaM( const EPaM& r) : nPara(r.nPara), nIndex(r.nIndex) {} + EPaM& operator = ( const EPaM& r ) { nPara = r.nPara; nIndex = r.nIndex; return *this; } + inline bool operator == ( const EPaM& r ) const; + inline bool operator < ( const EPaM& r ) const; +}; + +inline bool EPaM::operator < ( const EPaM& r ) const +{ + return ( nPara < r.nPara ) || ( ( nPara == r.nPara ) && nIndex < r.nIndex ); +} + +inline bool EPaM::operator == ( const EPaM& r ) const +{ + return ( nPara == r.nPara ) && ( nIndex == r.nIndex ); +} + +struct ScriptTypePosInfo +{ + short nScriptType; + sal_Int32 nStartPos; + sal_Int32 nEndPos; + + ScriptTypePosInfo( short Type, sal_Int32 Start, sal_Int32 End ) + : nScriptType(Type) + , nStartPos(Start) + , nEndPos(End) + { + } +}; + +typedef std::vector<ScriptTypePosInfo> ScriptTypePosInfos; + +struct WritingDirectionInfo +{ + sal_uInt8 nType; + sal_Int32 nStartPos; + sal_Int32 nEndPos; + + WritingDirectionInfo( sal_uInt8 Type, sal_Int32 Start, sal_Int32 End ) + : nType(Type) + , nStartPos(Start) + , nEndPos(End) + { + } +}; + + +typedef std::vector<WritingDirectionInfo> WritingDirectionInfos; + +class ContentAttribsInfo +{ +private: + typedef std::vector<std::unique_ptr<EditCharAttrib> > CharAttribsType; + + SfxItemSet aPrevParaAttribs; + CharAttribsType aPrevCharAttribs; + +public: + ContentAttribsInfo( SfxItemSet aParaAttribs ); + + const SfxItemSet& GetPrevParaAttribs() const { return aPrevParaAttribs; } + const CharAttribsType& GetPrevCharAttribs() const { return aPrevCharAttribs; } + + void RemoveAllCharAttribsFromPool(SfxItemPool& rPool) const; + void AppendCharAttrib(EditCharAttrib* pNew); +}; + + + +typedef std::vector<Color> SvxColorList; + + + + +class ItemList +{ +private: + typedef std::vector<const SfxPoolItem*> DummyItemList; + DummyItemList aItemPool; + sal_Int32 CurrentItem; + +public: + ItemList(); + const SfxPoolItem* First(); + const SfxPoolItem* Next(); + sal_Int32 Count() const { return aItemPool.size(); }; + void Insert( const SfxPoolItem* pItem ); + void Clear() { aItemPool.clear(); }; +}; + + + +class ContentAttribs +{ +private: + SfxStyleSheet* pStyle; + SfxItemSetFixed<EE_PARA_START, EE_CHAR_END> aAttribSet; + +public: + ContentAttribs( SfxItemPool& rItemPool ); + + void dumpAsXml(xmlTextWriterPtr pWriter) const; + + SvxTabStop FindTabStop( sal_Int32 nCurPos, sal_uInt16 nDefTab ); + SfxItemSet& GetItems() { return aAttribSet; } + const SfxItemSet& GetItems() const { return aAttribSet; } + const SfxStyleSheet* GetStyleSheet() const { return pStyle; } + SfxStyleSheet* GetStyleSheet() { return pStyle; } + void SetStyleSheet( SfxStyleSheet* pS ); + + const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const; + template<class T> + const T& GetItem( TypedWhichId<T> nWhich ) const + { + return static_cast<const T&>(GetItem(sal_uInt16(nWhich))); + } + bool HasItem( sal_uInt16 nWhich ) const; +}; + + + +class CharAttribList +{ +public: + typedef std::vector<std::unique_ptr<EditCharAttrib> > AttribsType; + +private: + AttribsType aAttribs; + SvxFont aDefFont; // faster than ever from the pool! + bool bHasEmptyAttribs; + +public: + CharAttribList(); + ~CharAttribList(); + + void dumpAsXml(xmlTextWriterPtr pWriter) const; + + void DeleteEmptyAttribs( SfxItemPool& rItemPool ); + + const EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos ) const; + EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos ); + const EditCharAttrib* FindNextAttrib( sal_uInt16 nWhich, sal_Int32 nFromPos ) const; + EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_Int32 nPos ); + const EditCharAttrib* FindFeature( sal_Int32 nPos ) const; + + + void ResortAttribs(); + void OptimizeRanges( SfxItemPool& rItemPool ); + + sal_Int32 Count() const; + + void InsertAttrib( EditCharAttrib* pAttrib ); + + SvxFont& GetDefFont() { return aDefFont; } + + bool HasEmptyAttribs() const { return bHasEmptyAttribs; } + void SetHasEmptyAttribs(bool b); + bool HasBoundingAttrib( sal_Int32 nBound ) const; + bool HasAttrib( sal_Int32 nStartPos, sal_Int32 nEndPos ) const; + + AttribsType& GetAttribs() { return aAttribs;} + const AttribsType& GetAttribs() const { return aAttribs;} + + void Remove(const EditCharAttrib* p); + void Remove(sal_Int32 nPos); + +#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG + static void DbgCheckAttribs(CharAttribList const& rAttribs); +#endif +}; + + + +class ContentNode +{ +private: + OUString maString; + ContentAttribs aContentAttribs; + CharAttribList aCharAttribList; + std::unique_ptr<WrongList> mpWrongList; + + void UnExpandPosition( sal_Int32 &rStartPos, bool bBiasStart ); + +public: + ContentNode( SfxItemPool& rItemPool ); + ContentNode( const OUString& rStr, const ContentAttribs& rContentAttribs ); + ~ContentNode(); + ContentNode(const ContentNode&) = delete; + ContentNode& operator=(const ContentNode&) = delete; + + void dumpAsXml(xmlTextWriterPtr pWriter) const; + + ContentAttribs& GetContentAttribs() { return aContentAttribs; } + const ContentAttribs& GetContentAttribs() const { return aContentAttribs; } + CharAttribList& GetCharAttribs() { return aCharAttribList; } + const CharAttribList& GetCharAttribs() const { return aCharAttribList; } + + void ExpandAttribs( sal_Int32 nIndex, sal_Int32 nNewChars, SfxItemPool& rItemPool ); + void CollapseAttribs( sal_Int32 nIndex, sal_Int32 nDelChars, SfxItemPool& rItemPool ); + void AppendAttribs( ContentNode* pNextNode ); + void CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool, bool bKeepEndingAttribs ); + + void SetStyleSheet( SfxStyleSheet* pS, bool bRecalcFont = true ); + void SetStyleSheet( SfxStyleSheet* pS, const SvxFont& rFontFromStyle ); + SfxStyleSheet* GetStyleSheet() { return aContentAttribs.GetStyleSheet(); } + + void CreateDefFont(); + + void EnsureWrongList(); + WrongList* GetWrongList(); + const WrongList* GetWrongList() const; + void SetWrongList( WrongList* p ); + + void CreateWrongList(); + void DestroyWrongList(); + + bool IsFeature( sal_Int32 nPos ) const; + + sal_Int32 Len() const; + const OUString& GetString() const { return maString;} + + /// return length including expanded fields + sal_Int32 GetExpandedLen() const; + /// return content including expanded fields + OUString GetExpandedText(sal_Int32 nStartPos = 0, sal_Int32 nEndPos = -1) const; + /// re-write offsets in the expanded text to string offsets + void UnExpandPositions( sal_Int32 &rStartPos, sal_Int32 &rEndPos ); + + void SetChar(sal_Int32 nPos, sal_Unicode c); + void Insert(std::u16string_view rStr, sal_Int32 nPos); + void Append(std::u16string_view rStr); + void Erase(sal_Int32 nPos); + void Erase(sal_Int32 nPos, sal_Int32 nCount); + OUString Copy(sal_Int32 nPos) const; + OUString Copy(sal_Int32 nPos, sal_Int32 nCount) const; + sal_Unicode GetChar(sal_Int32 nPos) const; +}; + + + +class EditPaM +{ +private: + ContentNode* pNode; + sal_Int32 nIndex; + +public: + EditPaM(); + EditPaM(ContentNode* p, sal_Int32 n); + + const ContentNode* GetNode() const { return pNode;} + ContentNode* GetNode() { return pNode;} + void SetNode(ContentNode* p); + + sal_Int32 GetIndex() const { return nIndex; } + void SetIndex( sal_Int32 n ) { nIndex = n; } + + bool DbgIsBuggy( EditDoc const & rDoc ) const; + + friend bool operator == ( const EditPaM& r1, const EditPaM& r2 ); + friend bool operator != ( const EditPaM& r1, const EditPaM& r2 ); + bool operator !() const { return !pNode && !nIndex; } +}; + +enum class PortionKind +{ + TEXT = 0, + TAB = 1, + LINEBREAK = 2, + FIELD = 3, + HYPHENATOR = 4 +}; + +enum class DeleteMode { + Simple, RestOfWord, RestOfContent +}; + +enum class AsianCompressionFlags { + Normal = 0x00, + Kana = 0x01, + PunctuationLeft = 0x02, + PunctuationRight = 0x04, +}; +namespace o3tl { + template<> struct typed_flags<AsianCompressionFlags> : is_typed_flags<AsianCompressionFlags, 0x07> {}; +} + + + +// struct ExtraPortionInfos + +struct ExtraPortionInfo +{ + tools::Long nOrgWidth; + tools::Long nWidthFullCompression; + + tools::Long nPortionOffsetX; + + sal_uInt16 nMaxCompression100thPercent; + + AsianCompressionFlags nAsianCompressionTypes; + bool bFirstCharIsRightPunktuation; + bool bCompressed; + + std::unique_ptr<sal_Int32[]> pOrgDXArray; + std::vector< sal_Int32 > lineBreaksList; + + + ExtraPortionInfo(); + ~ExtraPortionInfo(); + + void SaveOrgDXArray( const sal_Int32* pDXArray, sal_Int32 nLen ); +}; + + + +class TextPortion +{ +private: + std::unique_ptr<ExtraPortionInfo> xExtraInfos; + sal_Int32 nLen; + Size aOutSz; + PortionKind nKind; + sal_uInt8 nRightToLeftLevel; + sal_Unicode nExtraValue; + + +public: + TextPortion( sal_Int32 nL ) + : nLen( nL ) + , aOutSz( -1, -1 ) + , nKind( PortionKind::TEXT ) + , nRightToLeftLevel( 0 ) + , nExtraValue( 0 ) + { + } + + TextPortion( const TextPortion& r ) + : nLen( r.nLen ) + , aOutSz( r.aOutSz ) + , nKind( r.nKind ) + , nRightToLeftLevel( r.nRightToLeftLevel ) + , nExtraValue( r.nExtraValue ) + { + } + + + sal_Int32 GetLen() const { return nLen; } + void SetLen( sal_Int32 nL ) { nLen = nL; } + + Size& GetSize() { return aOutSz; } + const Size& GetSize() const { return aOutSz; } + + void SetKind(PortionKind n) { nKind = n; } + PortionKind GetKind() const { return nKind; } + + void SetRightToLeftLevel( sal_uInt8 n ) { nRightToLeftLevel = n; } + sal_uInt8 GetRightToLeftLevel() const { return nRightToLeftLevel; } + bool IsRightToLeft() const { return (nRightToLeftLevel&1); } + + sal_Unicode GetExtraValue() const { return nExtraValue; } + void SetExtraValue( sal_Unicode n ) { nExtraValue = n; } + + ExtraPortionInfo* GetExtraInfos() const { return xExtraInfos.get(); } + void SetExtraInfos( ExtraPortionInfo* p ) { xExtraInfos.reset(p); } +}; + + + +class TextPortionList +{ + typedef std::vector<std::unique_ptr<TextPortion> > PortionsType; + PortionsType maPortions; + +public: + TextPortionList(); + ~TextPortionList(); + + void Reset(); + sal_Int32 FindPortion( + sal_Int32 nCharPos, sal_Int32& rPortionStart, bool bPreferStartingPortion = false) const; + sal_Int32 GetStartPos(sal_Int32 nPortion); + void DeleteFromPortion(sal_Int32 nDelFrom); + sal_Int32 Count() const; + const TextPortion& operator[](sal_Int32 nPos) const; + TextPortion& operator[](sal_Int32 nPos); + + void Append(TextPortion* p); + void Insert(sal_Int32 nPos, TextPortion* p); + void Remove(sal_Int32 nPos); + sal_Int32 GetPos(const TextPortion* p) const; +}; + +class ParaPortion; + + + +class EditLine +{ +public: + typedef std::vector<sal_Int32> CharPosArrayType; + +private: + CharPosArrayType aPositions; + sal_Int32 nTxtWidth; + sal_Int32 nStartPosX; + sal_Int32 nStart; // could be replaced by nStartPortion + sal_Int32 nEnd; // could be replaced by nEndPortion + sal_Int32 nStartPortion; + sal_Int32 nEndPortion; + sal_uInt16 nHeight; // Total height of the line + sal_uInt16 nTxtHeight; // Pure Text height + sal_uInt16 nMaxAscent; + bool bHangingPunctuation:1; + bool bInvalid:1; // for skillful formatting + +public: + EditLine(); + EditLine( const EditLine& ); + ~EditLine(); + + bool IsIn( sal_Int32 nIndex ) const + { return ( (nIndex >= nStart ) && ( nIndex < nEnd ) ); } + + bool IsIn( sal_Int32 nIndex, bool bInclEnd ) const + { return ( ( nIndex >= nStart ) && ( bInclEnd ? ( nIndex <= nEnd ) : ( nIndex < nEnd ) ) ); } + + void SetStart( sal_Int32 n ) { nStart = n; } + sal_Int32 GetStart() const { return nStart; } + sal_Int32& GetStart() { return nStart; } + + void SetEnd( sal_Int32 n ) { nEnd = n; } + sal_Int32 GetEnd() const { return nEnd; } + sal_Int32& GetEnd() { return nEnd; } + + void SetStartPortion( sal_Int32 n ) { nStartPortion = n; } + sal_Int32 GetStartPortion() const { return nStartPortion; } + sal_Int32& GetStartPortion() { return nStartPortion; } + + void SetEndPortion( sal_Int32 n ) { nEndPortion = n; } + sal_Int32 GetEndPortion() const { return nEndPortion; } + sal_Int32& GetEndPortion() { return nEndPortion; } + + void SetHeight( sal_uInt16 nH, sal_uInt16 nTxtH = 0 ); + sal_uInt16 GetHeight() const { return nHeight; } + sal_uInt16 GetTxtHeight() const { return nTxtHeight; } + + void SetTextWidth( sal_Int32 n ) { nTxtWidth = n; } + sal_Int32 GetTextWidth() const { return nTxtWidth; } + + void SetMaxAscent( sal_uInt16 n ) { nMaxAscent = n; } + sal_uInt16 GetMaxAscent() const { return nMaxAscent; } + + void SetHangingPunctuation( bool b ) { bHangingPunctuation = b; } + bool IsHangingPunctuation() const { return bHangingPunctuation; } + + sal_Int32 GetLen() const { return nEnd - nStart; } + + sal_Int32 GetStartPosX() const { return nStartPosX; } + void SetStartPosX( sal_Int32 start ); + Size CalcTextSize( ParaPortion& rParaPortion ); + + bool IsInvalid() const { return bInvalid; } + bool IsValid() const { return !bInvalid; } + void SetInvalid() { bInvalid = true; } + void SetValid() { bInvalid = false; } + + bool IsEmpty() const { return nEnd <= nStart; } + + CharPosArrayType& GetCharPosArray() { return aPositions;} + const CharPosArrayType& GetCharPosArray() const { return aPositions;} + + EditLine* Clone() const; + + EditLine& operator = ( const EditLine& rLine ); + friend bool operator == ( const EditLine& r1, const EditLine& r2 ); +}; + + + +class EditLineList +{ + typedef std::vector<std::unique_ptr<EditLine> > LinesType; + LinesType maLines; + +public: + EditLineList(); + ~EditLineList(); + + void Reset(); + void DeleteFromLine(sal_Int32 nDelFrom); + sal_Int32 FindLine(sal_Int32 nChar, bool bInclEnd); + sal_Int32 Count() const; + const EditLine& operator[](sal_Int32 nPos) const; + EditLine& operator[](sal_Int32 nPos); + + void Append(EditLine* p); + void Insert(sal_Int32 nPos, EditLine* p); +}; + + + +class ParaPortion +{ + friend class ImpEditEngine; // to adjust the height +private: + EditLineList aLineList; + TextPortionList aTextPortionList; + ContentNode* pNode; + tools::Long nHeight; + + ScriptTypePosInfos aScriptInfos; + WritingDirectionInfos aWritingDirectionInfos; + + sal_Int32 nInvalidPosStart; + sal_Int32 nFirstLineOffset; // For Writer-LineSpacing-Interpretation + sal_Int32 nBulletX; + sal_Int32 nInvalidDiff; + + bool bInvalid : 1; + bool bSimple : 1; // only linear Tap + bool bVisible : 1; // Belongs to the node! + bool bForceRepaint : 1; + + ParaPortion( const ParaPortion& ) = delete; + +public: + ParaPortion( ContentNode* pNode ); + ~ParaPortion(); + + sal_Int32 GetLineNumber( sal_Int32 nIndex ) const; + + EditLineList& GetLines() { return aLineList; } + const EditLineList& GetLines() const { return aLineList; } + + bool IsInvalid() const { return bInvalid; } + bool IsSimpleInvalid() const { return bSimple; } + void SetValid() { bInvalid = false; bSimple = true;} + + bool MustRepaint() const { return bForceRepaint; } + void SetMustRepaint( bool bRP ) { bForceRepaint = bRP; } + + sal_Int32 GetBulletX() const { return nBulletX; } + void SetBulletX( sal_Int32 n ) { nBulletX = n; } + + void MarkInvalid( sal_Int32 nStart, sal_Int32 nDiff); + void MarkSelectionInvalid( sal_Int32 nStart ); + + void SetVisible( bool bVisible ); + bool IsVisible() const { return bVisible; } + + bool IsEmpty() { return GetTextPortions().Count() == 1 && GetTextPortions()[0].GetLen() == 0; } + + tools::Long GetHeight() const { return ( bVisible ? nHeight : 0 ); } + sal_Int32 GetFirstLineOffset() const { return ( bVisible ? nFirstLineOffset : 0 ); } + void ResetHeight() { nHeight = 0; nFirstLineOffset = 0; } + + ContentNode* GetNode() const { return pNode; } + TextPortionList& GetTextPortions() { return aTextPortionList; } + const TextPortionList& GetTextPortions() const { return aTextPortionList; } + + sal_Int32 GetInvalidPosStart() const { return nInvalidPosStart; } + short GetInvalidDiff() const { return nInvalidDiff; } + + void CorrectValuesBehindLastFormattedLine( sal_Int32 nLastFormattedLine ); +#if OSL_DEBUG_LEVEL > 0 + static bool DbgCheckTextPortions(ParaPortion const&); +#endif +}; + + + +class ParaPortionList +{ + mutable sal_Int32 nLastCache; + std::vector<std::unique_ptr<ParaPortion>> maPortions; +public: + ParaPortionList(); + ~ParaPortionList(); + + void Reset(); + tools::Long GetYOffset(const ParaPortion* pPPortion) const; + sal_Int32 FindParagraph(tools::Long nYOffset) const; + + const ParaPortion* SafeGetObject(sal_Int32 nPos) const; + ParaPortion* SafeGetObject(sal_Int32 nPos); + + sal_Int32 GetPos(const ParaPortion* p) const; + ParaPortion* operator[](sal_Int32 nPos); + const ParaPortion* operator[](sal_Int32 nPos) const; + + std::unique_ptr<ParaPortion> Release(sal_Int32 nPos); + void Remove(sal_Int32 nPos); + void Insert(sal_Int32 nPos, std::unique_ptr<ParaPortion> p); + void Append(std::unique_ptr<ParaPortion> p); + sal_Int32 Count() const; + +#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG + // temporary: + static void DbgCheck(ParaPortionList const&, EditDoc const& rDoc); +#endif +}; + + + +class EditSelection +{ +private: + EditPaM aStartPaM; + EditPaM aEndPaM; + +public: + EditSelection(); // No constructor and destructor + // are automatically executed correctly! + EditSelection( const EditPaM& rStartAndAnd ); + EditSelection( const EditPaM& rStart, const EditPaM& rEnd ); + + EditPaM& Min() { return aStartPaM; } + EditPaM& Max() { return aEndPaM; } + + const EditPaM& Min() const { return aStartPaM; } + const EditPaM& Max() const { return aEndPaM; } + + bool HasRange() const { return aStartPaM != aEndPaM; } + bool IsInvalid() const { return !aStartPaM || !aEndPaM; } + bool DbgIsBuggy( EditDoc const & rDoc ) const; + + void Adjust( const EditDoc& rNodes ); + + EditSelection& operator = ( const EditPaM& r ); + bool operator == ( const EditSelection& r ) const + { return ( aStartPaM == r.aStartPaM ) && ( aEndPaM == r.aEndPaM ); } + bool operator != ( const EditSelection& r ) const { return !( r == *this ); } +}; + + + +class DeletedNodeInfo +{ +private: + ContentNode* mpInvalidNode; + sal_Int32 nInvalidParagraph; + +public: + DeletedNodeInfo( ContentNode* pNode, sal_Int32 nPos ) + : mpInvalidNode(pNode) + , nInvalidParagraph(nPos) + { + } + + ContentNode* GetNode() const { return mpInvalidNode; } + sal_Int32 GetPosition() const { return nInvalidParagraph; } +}; + + + +class EditDoc +{ +private: + mutable sal_Int32 nLastCache; + std::vector<std::unique_ptr<ContentNode> > maContents; + + rtl::Reference<SfxItemPool> pItemPool; + Link<LinkParamNone*,void> aModifyHdl; + + SvxFont aDefFont; //faster than ever from the pool!! + sal_uInt16 nDefTab; + bool bIsVertical:1; + TextRotation mnRotation; + bool bIsFixedCellHeight:1; + + bool bModified:1; + bool bDisableAttributeExpanding:1; + +private: + void ImplDestroyContents(); + +public: + EditDoc( SfxItemPool* pItemPool ); + ~EditDoc(); + + void dumpAsXml(xmlTextWriterPtr pWriter) const; + void ClearSpellErrors(); + + bool IsModified() const { return bModified; } + void SetModified( bool b ); + + void DisableAttributeExpanding() { bDisableAttributeExpanding = true; } + + void SetModifyHdl( const Link<LinkParamNone*,void>& rLink ) { aModifyHdl = rLink; } + + void CreateDefFont( bool bUseStyles ); + const SvxFont& GetDefFont() const { return aDefFont; } + + void SetDefTab( sal_uInt16 nTab ) { nDefTab = nTab ? nTab : DEFTAB; } + sal_uInt16 GetDefTab() const { return nDefTab; } + + void SetVertical( bool bVertical ) { bIsVertical = bVertical; } + bool IsEffectivelyVertical() const; + bool IsTopToBottom() const; + bool GetVertical() const; + void SetRotation( TextRotation nRotation ) { mnRotation = nRotation; } + TextRotation GetRotation() const { return mnRotation; } + + void SetFixedCellHeight( bool bUseFixedCellHeight ) { bIsFixedCellHeight = bUseFixedCellHeight; } + bool IsFixedCellHeight() const { return bIsFixedCellHeight; } + + EditPaM Clear(); + EditPaM RemoveText(); + void RemoveChars( EditPaM aPaM, sal_Int32 nChars ); + EditPaM InsertText( EditPaM aPaM, const OUString& rStr ); + EditPaM InsertParaBreak( EditPaM aPaM, bool bKeepEndingAttribs ); + EditPaM InsertFeature( EditPaM aPaM, const SfxPoolItem& rItem ); + EditPaM ConnectParagraphs( ContentNode* pLeft, ContentNode* pRight ); + + OUString GetText( LineEnd eEnd ) const; + sal_Int32 GetTextLen() const; + + OUString GetParaAsString( sal_Int32 nNode ) const; + static OUString GetParaAsString(const ContentNode* pNode, sal_Int32 nStartPos = 0, sal_Int32 nEndPos = -1); + + EditPaM GetStartPaM() const; + EditPaM GetEndPaM() const; + + SfxItemPool& GetItemPool() { return *pItemPool; } + const SfxItemPool& GetItemPool() const { return *pItemPool; } + + void RemoveItemsFromPool(const ContentNode& rNode); + + void InsertAttrib( const SfxPoolItem& rItem, ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd ); + void InsertAttrib( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, const SfxPoolItem& rPoolItem ); + void InsertAttribInSelection( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, const SfxPoolItem& rPoolItem ); + bool RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, sal_uInt16 nWhich ); + bool RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEnd, EditCharAttrib*& rpStarting, EditCharAttrib*& rpEnding, sal_uInt16 nWhich ); + static void FindAttribs( ContentNode* pNode, sal_Int32 nStartPos, sal_Int32 nEndPos, SfxItemSet& rCurSet ); + + sal_Int32 GetPos(const ContentNode* pNode) const; + const ContentNode* GetObject(sal_Int32 nPos) const; + ContentNode* GetObject(sal_Int32 nPos); + sal_Int32 Count() const; + const ContentNode* operator[](sal_Int32 nPos) const; + ContentNode* operator[](sal_Int32 nPos); + void Insert(sal_Int32 nPos, ContentNode* p); + /// deletes + void Remove(sal_Int32 nPos); + /// does not delete + void Release(sal_Int32 nPos); + + static OUString GetSepStr( LineEnd eEnd ); +}; + +inline EditCharAttrib* GetAttrib(CharAttribList::AttribsType& rAttribs, std::size_t nAttr) +{ + return (nAttr < rAttribs.size()) ? rAttribs[nAttr].get() : nullptr; +} + +#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG +void CheckOrderedList(const CharAttribList::AttribsType& rAttribs); +#endif + +class EditEngineItemPool final : public SfxItemPool +{ +private: + std::shared_ptr<DefItems> m_xDefItems; +public: + EditEngineItemPool(); +private: + virtual ~EditEngineItemPool() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/editeng.hxx b/editeng/inc/editeng.hxx new file mode 100644 index 000000000..5b831efa3 --- /dev/null +++ b/editeng/inc/editeng.hxx @@ -0,0 +1,28 @@ +/* -*- 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 . + */ + +#pragma once + +#define MN_WORDLANGUAGE 998 +#define MN_PARALANGUAGE 999 +#define MN_ALTSTART 1000 +#define MN_AUTOSTART 2000 +#define MN_DICTSTART 3000 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/editxml.hxx b/editeng/inc/editxml.hxx new file mode 100644 index 000000000..650b7dfde --- /dev/null +++ b/editeng/inc/editxml.hxx @@ -0,0 +1,33 @@ +/* -*- 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 . + */ + +#pragma once + +class EditEngine; +class SvStream; +struct ESelection; +class EditPaM; + +/** this function exports the selected content of an edit engine into a xml stream*/ +extern void SvxWriteXML(EditEngine& rEditEngine, SvStream& rStream, const ESelection& rSel); + +/** this function imports xml from the stream into the selected of an edit engine */ +extern EditPaM SvxReadXML(EditEngine& rEditEngine, SvStream& rStream, const ESelection& rSel); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/edtspell.hxx b/editeng/inc/edtspell.hxx new file mode 100644 index 000000000..a63c39569 --- /dev/null +++ b/editeng/inc/edtspell.hxx @@ -0,0 +1,144 @@ +/* -*- 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 . + */ + +#pragma once + +#include <editeng/splwrap.hxx> +#include <editeng/svxacorr.hxx> +#include <editeng/svxenum.hxx> +#include <editeng/misspellrange.hxx> + +namespace com::sun::star::linguistic2 { + class XSpellChecker1; +} + + +class EditView; +class EditEngine; +class ContentNode; + +class EditSpellWrapper final : public SvxSpellWrapper +{ +private: + EditView* pEditView; + void CheckSpellTo(); + + virtual void SpellStart( SvxSpellArea eArea ) override; + virtual void SpellContinue() override; // Check area + virtual void ReplaceAll( const OUString &rNewText ) override; + virtual bool SpellMore() override; + +public: + EditSpellWrapper(weld::Widget* pWin, bool bIsStart, EditView* pView); +}; + +/** + * Keeps track of misspelled ranges in paragraph. + */ +class WrongList +{ + static constexpr size_t Valid = std::numeric_limits<size_t>::max(); + + std::vector<editeng::MisspellRange> maRanges; + size_t mnInvalidStart; + size_t mnInvalidEnd; + + bool DbgIsBuggy() const; + +public: + typedef std::vector<editeng::MisspellRange>::iterator iterator; + typedef std::vector<editeng::MisspellRange>::const_iterator const_iterator; + + WrongList(); + + const std::vector<editeng::MisspellRange>& GetRanges() const { return maRanges;} + void SetRanges( std::vector<editeng::MisspellRange>&& rRanges ); + + bool IsValid() const; + void SetValid(); + void SetInvalidRange( size_t nStart, size_t nEnd ); + void ResetInvalidRange( size_t nStart, size_t nEnd ); + + size_t GetInvalidStart() const { return mnInvalidStart; } + size_t GetInvalidEnd() const { return mnInvalidEnd; } + + void TextInserted( size_t nPos, size_t nLength, bool bPosIsSep ); + void TextDeleted( size_t nPos, size_t nLength ); + + void InsertWrong( size_t nStart, size_t nEnd ); + bool NextWrong( size_t& rnStart, size_t& rnEnd ) const; + bool HasWrong( size_t nStart, size_t nEnd ) const; + bool HasAnyWrong( size_t nStart, size_t nEnd ) const; + void ClearWrongs( size_t nStart, size_t nEnd, const ContentNode* pNode ); + void MarkWrongsInvalid(); + + WrongList* Clone() const; + + // #i102062# + bool operator==(const WrongList& rCompare) const; + + bool empty() const; + void push_back(const editeng::MisspellRange& rRange); + editeng::MisspellRange& back(); + const editeng::MisspellRange& back() const; + + iterator begin(); + iterator end(); + const_iterator begin() const; + const_iterator end() const; +}; + +class EdtAutoCorrDoc final : public SvxAutoCorrDoc +{ + EditEngine* mpEditEngine; + ContentNode* pCurNode; + sal_Int32 nCursor; + + bool bAllowUndoAction; + bool bUndoAction; + + void ImplStartUndoAction(); + +public: + EdtAutoCorrDoc(EditEngine* pE, ContentNode* pCurNode, sal_Int32 nCrsr, sal_Unicode cIns); + virtual ~EdtAutoCorrDoc() override; + + virtual bool Delete( sal_Int32 nStt, sal_Int32 nEnd ) override; + virtual bool Insert( sal_Int32 nPos, const OUString& rTxt ) override; + virtual bool Replace( sal_Int32 nPos, const OUString& rTxt ) override; + virtual bool ReplaceRange( sal_Int32 nPos, sal_Int32 nLen, const OUString& rTxt ) override; + + virtual void SetAttr( sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId, SfxPoolItem& ) override; + virtual bool SetINetAttr( sal_Int32 nStt, sal_Int32 nEnd, const OUString& rURL ) override; + + virtual OUString const* GetPrevPara(bool bAtNormalPos) override; + + virtual bool ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, + SvxAutoCorrect& rACorrect, OUString* pPara ) override; + virtual bool TransliterateRTLWord( sal_Int32& rSttPos, sal_Int32 nEndPos, + bool bApply = false ) override; + + + virtual LanguageType GetLanguage( sal_Int32 nPos ) const override; + + sal_Int32 GetCursor() const { return nCursor; } + +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/eerdll2.hxx b/editeng/inc/eerdll2.hxx new file mode 100644 index 000000000..76653e79c --- /dev/null +++ b/editeng/inc/eerdll2.hxx @@ -0,0 +1,67 @@ +/* -*- 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 . + */ + +#pragma once + +#include <com/sun/star/linguistic2/XLanguageGuessing.hpp> +#include <editeng/forbiddencharacterstable.hxx> +#include <vcl/virdev.hxx> + +class SfxPoolItem; +class VirtualDevice; + +namespace editeng +{ + class SharedVclResources + { + private: + VclPtr<VirtualDevice> m_pVirDev; + public: + SharedVclResources(); + ~SharedVclResources(); + VclPtr<VirtualDevice> const & GetVirtualDevice() const; + }; +} + +class DefItems +{ +public: + DefItems(); + std::vector<SfxPoolItem*> & getDefaults() { return mvDefItems; } + ~DefItems(); +private: + std::vector<SfxPoolItem*> mvDefItems; +}; + +class GlobalEditData +{ +private: + css::uno::Reference< css::linguistic2::XLanguageGuessing > xLanguageGuesser; + std::weak_ptr<DefItems> m_xDefItems; + std::shared_ptr<SvxForbiddenCharactersTable> xForbiddenCharsTable; + +public: + std::shared_ptr<DefItems> GetDefItems(); + + std::shared_ptr<SvxForbiddenCharactersTable> const & GetForbiddenCharsTable(); + void SetForbiddenCharsTable(std::shared_ptr<SvxForbiddenCharactersTable> const & xForbiddenChars ) { xForbiddenCharsTable = xForbiddenChars; } + css::uno::Reference< css::linguistic2::XLanguageGuessing > const & GetLanguageGuesser(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/pch/precompiled_editeng.cxx b/editeng/inc/pch/precompiled_editeng.cxx new file mode 100644 index 000000000..87feb9c49 --- /dev/null +++ b/editeng/inc/pch/precompiled_editeng.cxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "precompiled_editeng.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/pch/precompiled_editeng.hxx b/editeng/inc/pch/precompiled_editeng.hxx new file mode 100644 index 000000000..b37710e16 --- /dev/null +++ b/editeng/inc/pch/precompiled_editeng.hxx @@ -0,0 +1,325 @@ +/* -*- 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 has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2021-07-28 20:17:03 using: + ./bin/update_pch editeng editeng --cutoff=5 --exclude:system --include:module --exclude:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./editeng/inc/pch/precompiled_editeng.hxx "make editeng.build" --find-conflicts +*/ + +#include <sal/config.h> +#if PCH_LEVEL >= 1 +#include <algorithm> +#include <array> +#include <assert.h> +#include <atomic> +#include <cassert> +#include <chrono> +#include <cmath> +#include <cstddef> +#include <cstdlib> +#include <cstring> +#include <deque> +#include <float.h> +#include <functional> +#include <initializer_list> +#include <iomanip> +#include <limits.h> +#include <limits> +#include <map> +#include <math.h> +#include <memory> +#include <new> +#include <numeric> +#include <optional> +#include <ostream> +#include <set> +#include <stddef.h> +#include <string.h> +#include <string> +#include <string_view> +#include <type_traits> +#include <unordered_map> +#include <utility> +#include <vector> +#include <boost/property_tree/json_parser.hpp> +#include <boost/property_tree/ptree.hpp> +#include <boost/property_tree/ptree_fwd.hpp> +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include <osl/diagnose.h> +#include <osl/doublecheckedlocking.h> +#include <osl/endian.h> +#include <osl/file.hxx> +#include <osl/getglobalmutex.hxx> +#include <osl/interlck.h> +#include <osl/mutex.h> +#include <osl/mutex.hxx> +#include <osl/thread.h> +#include <osl/time.h> +#include <rtl/alloc.h> +#include <rtl/character.hxx> +#include <rtl/instance.hxx> +#include <rtl/math.h> +#include <rtl/math.hxx> +#include <rtl/ref.hxx> +#include <rtl/strbuf.h> +#include <rtl/string.h> +#include <rtl/string.hxx> +#include <rtl/stringconcat.hxx> +#include <rtl/stringutils.hxx> +#include <rtl/tencinfo.h> +#include <rtl/textcvt.h> +#include <rtl/textenc.h> +#include <rtl/ustrbuf.hxx> +#include <rtl/ustring.h> +#include <rtl/ustring.hxx> +#include <rtl/uuid.h> +#include <sal/backtrace.hxx> +#include <sal/log.hxx> +#include <sal/macros.h> +#include <sal/saldllapi.h> +#include <sal/types.h> +#include <sal/typesizes.h> +#include <vcl/BinaryDataContainer.hxx> +#include <vcl/GraphicExternalLink.hxx> +#include <vcl/Scanline.hxx> +#include <vcl/alpha.hxx> +#include <vcl/animate/Animation.hxx> +#include <vcl/animate/AnimationBitmap.hxx> +#include <vcl/bitmap.hxx> +#include <vcl/bitmap/BitmapTypes.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/checksum.hxx> +#include <vcl/dllapi.h> +#include <vcl/errcode.hxx> +#include <vcl/font.hxx> +#include <vcl/gfxlink.hxx> +#include <vcl/graph.hxx> +#include <vcl/mapmod.hxx> +#include <vcl/metric.hxx> +#include <vcl/outdev.hxx> +#include <vcl/region.hxx> +#include <vcl/scopedbitmapaccess.hxx> +#include <vcl/settings.hxx> +#include <vcl/svapp.hxx> +#include <vcl/task.hxx> +#include <vcl/timer.hxx> +#include <vcl/vclenum.hxx> +#include <vcl/vclptr.hxx> +#include <vcl/vectorgraphicdata.hxx> +#include <vcl/weld.hxx> +#include <vcl/window.hxx> +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include <basegfx/basegfxdllapi.h> +#include <basegfx/color/bcolor.hxx> +#include <basegfx/numeric/ftools.hxx> +#include <basegfx/point/b2dpoint.hxx> +#include <basegfx/point/b2ipoint.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/range/b2drange.hxx> +#include <basegfx/range/basicrange.hxx> +#include <basegfx/tuple/Tuple2D.hxx> +#include <basegfx/tuple/Tuple3D.hxx> +#include <basegfx/tuple/b2dtuple.hxx> +#include <basegfx/tuple/b2ituple.hxx> +#include <basegfx/tuple/b3dtuple.hxx> +#include <basegfx/utils/common.hxx> +#include <basegfx/vector/b2dsize.hxx> +#include <basegfx/vector/b2dvector.hxx> +#include <basegfx/vector/b2enums.hxx> +#include <basegfx/vector/b2ivector.hxx> +#include <com/sun/star/accessibility/XAccessibleComponent.hpp> +#include <com/sun/star/accessibility/XAccessibleContext2.hpp> +#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> +#include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp> +#include <com/sun/star/awt/Key.hpp> +#include <com/sun/star/awt/KeyGroup.hpp> +#include <com/sun/star/i18n/ScriptType.hpp> +#include <com/sun/star/i18n/TransliterationModules.hpp> +#include <com/sun/star/i18n/TransliterationModulesExtra.hpp> +#include <com/sun/star/i18n/WordType.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/lang/EventObject.hpp> +#include <com/sun/star/lang/IndexOutOfBoundsException.hpp> +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/style/NumberingType.hpp> +#include <com/sun/star/uno/Any.h> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Exception.hpp> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/uno/Type.h> +#include <com/sun/star/uno/TypeClass.hdl> +#include <com/sun/star/uno/XAggregation.hpp> +#include <com/sun/star/uno/XInterface.hpp> +#include <com/sun/star/uno/XWeak.hpp> +#include <com/sun/star/uno/genfunc.h> +#include <com/sun/star/uno/genfunc.hxx> +#include <com/sun/star/util/Date.hpp> +#include <com/sun/star/util/DateTime.hpp> +#include <com/sun/star/util/Time.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/xml/sax/XFastAttributeList.hpp> +#include <com/sun/star/xml/sax/XFastContextHandler.hpp> +#include <com/sun/star/xml/sax/XFastTokenHandler.hpp> +#include <comphelper/accessiblecomponenthelper.hxx> +#include <comphelper/accessiblecontexthelper.hxx> +#include <comphelper/comphelperdllapi.h> +#include <comphelper/processfactory.hxx> +#include <comphelper/sequence.hxx> +#include <comphelper/solarmutex.hxx> +#include <comphelper/string.hxx> +#include <comphelper/uno3.hxx> +#include <cppu/cppudllapi.h> +#include <cppu/unotype.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase2.hxx> +#include <cppuhelper/compbase_ex.hxx> +#include <cppuhelper/cppuhelperdllapi.h> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase_ex.hxx> +#include <cppuhelper/implbase_ex_post.hxx> +#include <cppuhelper/implbase_ex_pre.hxx> +#include <cppuhelper/interfacecontainer.h> +#include <cppuhelper/supportsservice.hxx> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/weakagg.hxx> +#include <cppuhelper/weakref.hxx> +#include <i18nlangtag/lang.h> +#include <i18nlangtag/languagetag.hxx> +#include <i18nutil/i18nutildllapi.h> +#include <i18nutil/transliteration.hxx> +#include <libxml/xmlwriter.h> +#include <o3tl/cow_wrapper.hxx> +#include <o3tl/safeint.hxx> +#include <o3tl/span.hxx> +#include <o3tl/strong_int.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <o3tl/underlyingenumvalue.hxx> +#include <o3tl/unit_conversion.hxx> +#include <salhelper/salhelperdllapi.h> +#include <salhelper/simplereferenceobject.hxx> +#include <sax/fastattribs.hxx> +#include <sax/saxdllapi.h> +#include <sfx2/dllapi.h> +#include <sfx2/shell.hxx> +#include <sot/formats.hxx> +#include <sot/sotdllapi.h> +#include <svl/SfxBroadcaster.hxx> +#include <svl/cintitem.hxx> +#include <svl/eitem.hxx> +#include <svl/hint.hxx> +#include <svl/intitem.hxx> +#include <svl/itempool.hxx> +#include <svl/itemset.hxx> +#include <svl/lstner.hxx> +#include <svl/poolitem.hxx> +#include <svl/svldllapi.h> +#include <svl/typedwhich.hxx> +#include <svtools/svtdllapi.h> +#include <tools/UnitConversion.hxx> +#include <tools/color.hxx> +#include <tools/date.hxx> +#include <tools/datetime.hxx> +#include <tools/debug.hxx> +#include <tools/degree.hxx> +#include <tools/diagnose_ex.h> +#include <tools/fontenum.hxx> +#include <tools/gen.hxx> +#include <tools/link.hxx> +#include <tools/long.hxx> +#include <tools/mapunit.hxx> +#include <tools/ref.hxx> +#include <tools/solar.h> +#include <tools/stream.hxx> +#include <tools/time.hxx> +#include <tools/toolsdllapi.h> +#include <tools/urlobj.hxx> +#include <typelib/typeclass.h> +#include <typelib/typedescription.h> +#include <typelib/uik.h> +#include <uno/any2.h> +#include <uno/data.h> +#include <uno/sequence2.h> +#include <unotools/options.hxx> +#include <unotools/unotoolsdllapi.h> +#include <xmloff/dllapi.h> +#include <xmloff/families.hxx> +#include <xmloff/namespacemap.hxx> +#include <xmloff/xmltoken.hxx> +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include <editeng/adjustitem.hxx> +#include <editeng/autokernitem.hxx> +#include <editeng/brushitem.hxx> +#include <editeng/charreliefitem.hxx> +#include <editeng/charscaleitem.hxx> +#include <editeng/cmapitem.hxx> +#include <editeng/colritem.hxx> +#include <editeng/contouritem.hxx> +#include <editeng/crossedoutitem.hxx> +#include <editeng/editdata.hxx> +#include <editeng/editeng.hxx> +#include <editeng/editengdllapi.h> +#include <editeng/editstat.hxx> +#include <editeng/editview.hxx> +#include <editeng/eeitem.hxx> +#include <editeng/eerdll.hxx> +#include <editeng/emphasismarkitem.hxx> +#include <editeng/escapementitem.hxx> +#include <editeng/fhgtitem.hxx> +#include <editeng/flditem.hxx> +#include <editeng/fontitem.hxx> +#include <editeng/forbiddencharacterstable.hxx> +#include <editeng/frmdiritem.hxx> +#include <editeng/itemtype.hxx> +#include <editeng/kernitem.hxx> +#include <editeng/langitem.hxx> +#include <editeng/lrspitem.hxx> +#include <editeng/lspcitem.hxx> +#include <editeng/memberids.h> +#include <editeng/numitem.hxx> +#include <editeng/outliner.hxx> +#include <editeng/outlobj.hxx> +#include <editeng/postitem.hxx> +#include <editeng/scriptspaceitem.hxx> +#include <editeng/shdditem.hxx> +#include <editeng/svxenum.hxx> +#include <editeng/svxfont.hxx> +#include <editeng/tstpitem.hxx> +#include <editeng/udlnitem.hxx> +#include <editeng/ulspitem.hxx> +#include <editeng/unoedsrc.hxx> +#include <editeng/unoipset.hxx> +#include <editeng/unolingu.hxx> +#include <editeng/unoprnms.hxx> +#include <editeng/unotext.hxx> +#include <editeng/wghtitem.hxx> +#include <editeng/wrlmitem.hxx> +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/strings.hrc b/editeng/inc/strings.hrc new file mode 100644 index 000000000..b527e390d --- /dev/null +++ b/editeng/inc/strings.hrc @@ -0,0 +1,44 @@ +/* -*- 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/. + */ + +#pragma once + +#include <unotools/resmgr.hxx> + +#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String)) + +const TranslateId RID_SVXITEMS_HORJUST[] = +{ + // enum SvxCellHorJustify ---------------------------------------------------- + NC_("RID_SVXITEMS_HORJUST_STANDARD", "Horizontal alignment default"), + NC_("RID_SVXITEMS_HORJUST_LEFT", "Align left"), + NC_("RID_SVXITEMS_HORJUST_CENTER", "Centered horizontally"), + NC_("RID_SVXITEMS_HORJUST_RIGHT", "Align right"), + NC_("RID_SVXITEMS_HORJUST_BLOCK", "Justify horizontally"), + NC_("RID_SVXITEMS_HORJUST_REPEAT", "Repeat alignment") +}; + +const TranslateId RID_SVXITEMS_VERJUST[] = +{ + // enum SvxCellVerJustify ---------------------------------------------------- + NC_("RID_SVXITEMS_VERJUST_STANDARD", "Vertical alignment default"), + NC_("RID_SVXITEMS_VERJUST_TOP", "Align to top"), + NC_("RID_SVXITEMS_VERJUST_CENTER", "Centered vertically"), + NC_("RID_SVXITEMS_VERJUST_BOTTOM", "Align to bottom"), + NC_("RID_SVXITEMS_HORJUST_BLOCK", "Justify vertically") +}; + +const TranslateId RID_SVXITEMS_JUSTMETHOD[] = +{ + // enum SvxCellJustifyMethod ---------------------------------------------------- + NC_("RID_SVXITEMS_JUSTMETHOD_AUTO", "Automatic Justify"), + NC_("RID_SVXITEMS_JUSTMETHOD_DISTRIBUTE", "Distributed Justify") +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/unomodel.hxx b/editeng/inc/unomodel.hxx new file mode 100644 index 000000000..cfe5b59ee --- /dev/null +++ b/editeng/inc/unomodel.hxx @@ -0,0 +1,68 @@ +/* -*- 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 . + */ + +#pragma once + +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/ucb/XAnyCompareFactory.hpp> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <cppuhelper/implbase4.hxx> + +class SvxSimpleUnoModel final : public cppu::WeakAggImplHelper4< + css::frame::XModel, + css::ucb::XAnyCompareFactory, + css::style::XStyleFamiliesSupplier, + css::lang::XMultiServiceFactory > +{ +public: + SvxSimpleUnoModel(); + + // XMultiServiceFactory + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) override; + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames( ) override; + + // XStyleFamiliesSupplier + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getStyleFamilies( ) override; + + // XAnyCompareFactory + virtual css::uno::Reference< css::ucb::XAnyCompare > SAL_CALL createAnyCompareByName( const OUString& PropertyName ) override; + + // XModel + virtual sal_Bool SAL_CALL attachResource( const OUString& aURL, const css::uno::Sequence< css::beans::PropertyValue >& aArgs ) override; + virtual OUString SAL_CALL getURL( ) override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getArgs( ) override; + virtual void SAL_CALL connectController( const css::uno::Reference< css::frame::XController >& xController ) override; + virtual void SAL_CALL disconnectController( const css::uno::Reference< css::frame::XController >& xController ) override; + virtual void SAL_CALL lockControllers( ) override; + virtual void SAL_CALL unlockControllers( ) override; + virtual sal_Bool SAL_CALL hasControllersLocked( ) override; + virtual css::uno::Reference< css::frame::XController > SAL_CALL getCurrentController( ) override; + virtual void SAL_CALL setCurrentController( const css::uno::Reference< css::frame::XController >& xController ) override; + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getCurrentSelection( ) override; + + // XComponent + virtual void SAL_CALL dispose( ) override; + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; + +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/unopracc.hxx b/editeng/inc/unopracc.hxx new file mode 100644 index 000000000..03fd268e7 --- /dev/null +++ b/editeng/inc/unopracc.hxx @@ -0,0 +1,56 @@ +/* -*- 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 . + */ + +#pragma once + +#include <editeng/unotext.hxx> + +class SvxEditSource; + +/** Wraps SvxUnoTextRangeBase and provides us with the text properties + + Inherits from SvxUnoTextRangeBase and provides XPropertySet and + XMultiPropertySet interfaces. Just set the selection to the + required text range and return a reference to a XPropertySet. + */ +class SvxAccessibleTextPropertySet final : public SvxUnoTextRangeBase, + public css::lang::XTypeProvider, + public ::cppu::OWeakObject +{ +public: + SvxAccessibleTextPropertySet(const SvxEditSource*, const SvxItemPropertySet*); + virtual ~SvxAccessibleTextPropertySet() noexcept override; + + // XTextRange + virtual css::uno::Reference<css::text::XText> SAL_CALL getText() override; + + virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& rType) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + + // lang::XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString&) override; + + // lang::XTypeProvider + virtual css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() override; + virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |