diff options
-rw-r--r-- | svx/inc/sdr/properties/cellproperties.hxx | 81 | ||||
-rw-r--r-- | svx/source/inc/cell.hxx | 8 | ||||
-rw-r--r-- | svx/source/table/cell.cxx | 69 | ||||
-rw-r--r-- | svx/source/table/tablecolumn.cxx | 1 | ||||
-rw-r--r-- | svx/source/table/tablemodel.cxx | 1 | ||||
-rw-r--r-- | svx/source/table/tablerow.cxx | 1 | ||||
-rw-r--r-- | svx/source/table/tableundo.cxx | 16 | ||||
-rw-r--r-- | svx/source/table/tableundo.hxx | 6 |
8 files changed, 106 insertions, 77 deletions
diff --git a/svx/inc/sdr/properties/cellproperties.hxx b/svx/inc/sdr/properties/cellproperties.hxx new file mode 100644 index 000000000000..ce8dd062bb66 --- /dev/null +++ b/svx/inc/sdr/properties/cellproperties.hxx @@ -0,0 +1,81 @@ +/* -*- 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 "textproperties.hxx" +#include <svx/itextprovider.hxx> +#include <rtl/ref.hxx> + +namespace sdr::table +{ +class Cell; +typedef rtl::Reference<sdr::table::Cell> CellRef; +} + +namespace sdr::properties +{ +class CellTextProvider : public svx::ITextProvider +{ +public: + explicit CellTextProvider(sdr::table::CellRef xCell); + virtual ~CellTextProvider(); + +private: + virtual sal_Int32 getTextCount() const override; + virtual SdrText* getText(sal_Int32 nIndex) const override; + +private: + const sdr::table::CellRef m_xCell; +}; + +class CellProperties : public TextProperties +{ +protected: + // create a new itemset + SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& rPool) override; + + const svx::ITextProvider& getTextProvider() const override; + +public: + // basic constructor + CellProperties(SdrObject& rObj, ::sdr::table::Cell* pCell); + + // constructor for copying, but using new object + CellProperties(const CellProperties& rProps, SdrObject& rObj, sdr::table::Cell* pCell); + ~CellProperties(); + + // Clone() operator, normally just calls the local copy constructor + std::unique_ptr<BaseProperties> Clone(SdrObject& rObj) const override; + + void ForceDefaultAttributes() override; + + void ItemSetChanged(o3tl::span<const SfxPoolItem* const> aChangedItems, + sal_uInt16 nDeletedWhich) override; + + void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) override; + + sdr::table::CellRef mxCell; + +private: + const CellTextProvider maTextProvider; +}; + +} // namespace sdr::properties + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/inc/cell.hxx b/svx/source/inc/cell.hxx index 34ae09223ce5..b70c683ddde1 100644 --- a/svx/source/inc/cell.hxx +++ b/svx/source/inc/cell.hxx @@ -37,7 +37,7 @@ class SfxItemSet; class OutlinerParaObject; class SdrObject; -namespace sdr::properties { class TextProperties; } +namespace sdr::properties { class CellProperties; } namespace sdr::table { @@ -173,9 +173,7 @@ public: using SvxUnoTextRangeBase::setPropertyValue; using SvxUnoTextRangeBase::getPropertyValue; - SVX_DLLPRIVATE sdr::properties::TextProperties* CloneProperties( SdrObject& rNewObj, Cell& rNewCell ); - - SVX_DLLPRIVATE static sdr::properties::TextProperties* CloneProperties( sdr::properties::TextProperties const * pProperties, SdrObject& rNewObj, Cell& rNewCell ); + SVX_DLLPRIVATE sdr::properties::CellProperties* CloneProperties( SdrObject& rNewObj, Cell& rNewCell ); SVX_DLLPRIVATE void notifyModified(); @@ -196,7 +194,7 @@ private: const SvxItemPropertySet* mpPropSet; - std::unique_ptr<sdr::properties::TextProperties> mpProperties; + std::unique_ptr<sdr::properties::CellProperties> mpProperties; css::table::CellContentType mnCellContentType; diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index d1dbd0f8088f..432084a40b83 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -36,6 +36,7 @@ #include <libxml/xmlwriter.h> #include <sdr/properties/textproperties.hxx> +#include <sdr/properties/cellproperties.hxx> #include <editeng/outlobj.hxx> #include <editeng/writingmodeitem.hxx> #include <svx/svdotable.hxx> @@ -108,22 +109,8 @@ static const SvxItemPropertySet* ImplGetSvxCellPropertySet() return &aSvxCellPropertySet; } -namespace -{ - -class CellTextProvider : public svx::ITextProvider +namespace sdr::properties { -public: - explicit CellTextProvider(sdr::table::CellRef xCell); - virtual ~CellTextProvider(); - -private: - virtual sal_Int32 getTextCount() const override; - virtual SdrText* getText(sal_Int32 nIndex) const override; - -private: - const sdr::table::CellRef m_xCell; -}; CellTextProvider::CellTextProvider(sdr::table::CellRef xCell) : m_xCell(std::move(xCell)) @@ -146,40 +133,6 @@ SdrText* CellTextProvider::getText(sal_Int32 nIndex) const return m_xCell.get(); } -} - -namespace sdr::properties -{ - class CellProperties : public TextProperties - { - protected: - // create a new itemset - SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& rPool) override; - - const svx::ITextProvider& getTextProvider() const override; - - public: - // basic constructor - CellProperties(SdrObject& rObj, sdr::table::Cell* pCell ); - - // constructor for copying, but using new object - CellProperties(const CellProperties& rProps, SdrObject& rObj, sdr::table::Cell* pCell); - - // Clone() operator, normally just calls the local copy constructor - std::unique_ptr<BaseProperties> Clone(SdrObject& rObj) const override; - - void ForceDefaultAttributes() override; - - void ItemSetChanged(o3tl::span< const SfxPoolItem* const > aChangedItems, sal_uInt16 nDeletedWhich) override; - - void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) override; - - sdr::table::CellRef mxCell; - - private: - const CellTextProvider maTextProvider; - }; - // create a new itemset SfxItemSet CellProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) { @@ -216,6 +169,10 @@ namespace sdr::properties { } + CellProperties::~CellProperties() + { + } + std::unique_ptr<BaseProperties> CellProperties::Clone(SdrObject& rObj) const { OSL_FAIL("CellProperties::Clone(), does not work yet!"); @@ -826,19 +783,11 @@ void Cell::AddUndo() } } - -sdr::properties::TextProperties* Cell::CloneProperties( sdr::properties::TextProperties const * pProperties, SdrObject& rNewObj, Cell& rNewCell ) +sdr::properties::CellProperties* Cell::CloneProperties( SdrObject& rNewObj, Cell& rNewCell ) { - if( pProperties ) - return new sdr::properties::CellProperties( *static_cast<sdr::properties::CellProperties const *>(pProperties), rNewObj, &rNewCell ); - else + if (!mpProperties) return nullptr; -} - - -sdr::properties::TextProperties* Cell::CloneProperties( SdrObject& rNewObj, Cell& rNewCell ) -{ - return CloneProperties(mpProperties.get(),rNewObj,rNewCell); + return new sdr::properties::CellProperties( *mpProperties, rNewObj, &rNewCell ); } diff --git a/svx/source/table/tablecolumn.cxx b/svx/source/table/tablecolumn.cxx index 9638787237a0..a13b3073be25 100644 --- a/svx/source/table/tablecolumn.cxx +++ b/svx/source/table/tablecolumn.cxx @@ -24,6 +24,7 @@ #include <tablemodel.hxx> #include "tablecolumn.hxx" #include "tableundo.hxx" +#include <sdr/properties/cellproperties.hxx> #include <svx/svdmodel.hxx> #include <svx/svdotable.hxx> #include <utility> diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx index 0e0cb45179c7..5dcbcf7ce617 100644 --- a/svx/source/table/tablemodel.cxx +++ b/svx/source/table/tablemodel.cxx @@ -39,6 +39,7 @@ #include "tablecolumns.hxx" #include "tableundo.hxx" #include <o3tl/safeint.hxx> +#include <sdr/properties/cellproperties.hxx> #include <svx/svdotable.hxx> #include <svx/svdmodel.hxx> #include <svx/strings.hrc> diff --git a/svx/source/table/tablerow.cxx b/svx/source/table/tablerow.cxx index 5ea999413c3d..90fa84acb9c9 100644 --- a/svx/source/table/tablerow.cxx +++ b/svx/source/table/tablerow.cxx @@ -24,6 +24,7 @@ #include <cell.hxx> #include "tablerow.hxx" #include "tableundo.hxx" +#include <sdr/properties/cellproperties.hxx> #include <svx/svdmodel.hxx> #include <svx/svdotable.hxx> #include <utility> diff --git a/svx/source/table/tableundo.cxx b/svx/source/table/tableundo.cxx index 5138baa20a7c..060cd2ae4f6f 100644 --- a/svx/source/table/tableundo.cxx +++ b/svx/source/table/tableundo.cxx @@ -18,7 +18,7 @@ */ -#include <sdr/properties/textproperties.hxx> +#include <sdr/properties/cellproperties.hxx> #include <editeng/outlobj.hxx> #include <cell.hxx> @@ -57,10 +57,8 @@ CellUndo::~CellUndo() void CellUndo::dispose() { mxCell.clear(); - delete maUndoData.mpProperties; - maUndoData.mpProperties = nullptr; - delete maRedoData.mpProperties; - maRedoData.mpProperties = nullptr; + maUndoData.mxProperties.reset(); + maRedoData.mxProperties.reset(); maUndoData.mpOutlinerParaObject.reset(); maRedoData.mpOutlinerParaObject.reset(); } @@ -74,7 +72,7 @@ void CellUndo::Undo() { if( mxCell.is() && mbUndo ) { - if( maRedoData.mpProperties == nullptr ) + if( !maRedoData.mxProperties ) getDataFromCell( maRedoData ); setDataToCell( maUndoData ); @@ -99,8 +97,8 @@ bool CellUndo::Merge( SfxUndoAction *pNextAction ) void CellUndo::setDataToCell( const Data& rData ) { - if( rData.mpProperties ) - mxCell->mpProperties.reset(Cell::CloneProperties( rData.mpProperties, *mxObjRef.get(), *mxCell )); + if( rData.mxProperties ) + mxCell->mpProperties.reset(new properties::CellProperties( *rData.mxProperties, *mxObjRef.get(), mxCell.get() )); else mxCell->mpProperties.reset(); @@ -131,7 +129,7 @@ void CellUndo::getDataFromCell( Data& rData ) return; if( mxCell->mpProperties ) - rData.mpProperties = mxCell->CloneProperties( *mxObjRef.get(), *mxCell); + rData.mxProperties.reset( mxCell->CloneProperties( *mxObjRef.get(), *mxCell) ); if( mxCell->GetOutlinerParaObject() ) rData.mpOutlinerParaObject = *mxCell->GetOutlinerParaObject(); diff --git a/svx/source/table/tableundo.hxx b/svx/source/table/tableundo.hxx index 4241950396ca..166d0a33a07a 100644 --- a/svx/source/table/tableundo.hxx +++ b/svx/source/table/tableundo.hxx @@ -22,6 +22,7 @@ #include <com/sun/star/container/XIndexAccess.hpp> +#include <sdr/properties/cellproperties.hxx> #include <svx/svdotable.hxx> #include <svx/svdobj.hxx> #include <svx/svdundo.hxx> @@ -54,7 +55,7 @@ public: private: struct Data { - sdr::properties::TextProperties* mpProperties; + std::unique_ptr<sdr::properties::CellProperties> mxProperties; std::optional<OutlinerParaObject> mpOutlinerParaObject; OUString msFormula; @@ -65,8 +66,7 @@ private: ::sal_Int32 mnColSpan; Data() - : mpProperties(nullptr) - , mfValue(0) + : mfValue(0) , mnError(0) , mbMerged(false) , mnRowSpan(0) |