Calc: Adapt 'SvxAutoFormat'

Adapt 'SvxAutoFormat' and retire Calc specific 'AutoFormat' dialog and
preview

Change-Id: I7d1146ba3612c2bd528a4f0daa5485a9c0296dea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190026
Tested-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
This commit is contained in:
Karthik
2026-02-04 14:02:17 +01:00
committed by Heiko Tietze
parent 01253d0ead
commit a8cfe77dd7
30 changed files with 1653 additions and 2405 deletions
+6
View File
@@ -11,4 +11,10 @@
$(eval $(call sc_unoapi_common,autoformatsobj))
.PHONY: restore-default-autoformats
restore-default-autoformats:
-cp "sc/res/xml/tablestyles.xml" "$(INSTROOT)/$(LIBO_SHARE_FOLDER)/calc/tablestyles.xml"
$(call gb_CppunitTest_get_target,sc_autoformatsobj): restore-default-autoformats
# vim: set noet sw=4 ts=4:
-1
View File
@@ -504,7 +504,6 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/formdlg/formula \
sc/source/ui/miscdlgs/acredlin \
sc/source/ui/miscdlgs/anyrefdg \
sc/source/ui/miscdlgs/autofmt \
sc/source/ui/miscdlgs/conflictsdlg \
sc/source/ui/miscdlgs/crnrdlg \
sc/source/ui/miscdlgs/datastreamdlg \
-1
View File
@@ -107,7 +107,6 @@ $(eval $(call gb_Library_add_exception_objects,scui,\
sc/source/ui/miscdlgs/mtrindlg \
sc/source/ui/miscdlgs/mvtabdlg \
sc/source/ui/miscdlgs/namecrea \
sc/source/ui/miscdlgs/scuiautofmt \
sc/source/ui/miscdlgs/shtabdlg \
sc/source/ui/miscdlgs/strindlg \
sc/source/ui/miscdlgs/tabbgcolordlg \
-1
View File
@@ -138,7 +138,6 @@ $(eval $(call gb_Module_add_slowcheck_targets,sc, \
CppunitTest_sc_arealinkobj \
CppunitTest_sc_arealinksobj \
CppunitTest_sc_autoformatobj \
CppunitTest_sc_autoformatsobj \
CppunitTest_sc_cellcursorobj \
CppunitTest_sc_cellfieldsobj \
CppunitTest_sc_cellformatsenumeration \
+1
View File
@@ -11,6 +11,7 @@ $(eval $(call gb_Package_Package,sc_res_xml,$(SRCDIR)/sc/res/xml))
$(eval $(call gb_Package_add_files,sc_res_xml,$(LIBO_SHARE_FOLDER)/calc,\
styles.xml \
tablestyles.xml \
))
# vim: set noet sw=4 ts=4:
+36 -162
View File
@@ -19,198 +19,72 @@
#pragma once
/*************************************************************************
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
The structure of auto formatting should not be changed. It is used
by various code of Writer and Calc. If a change is necessary, the
source code of both applications must be changed!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
**************************************************************************/
#include <svl/poolitem.hxx>
#include <svx/autoformathelper.hxx>
#include <sal/types.h>
#include <svx/TableAutoFmt.hxx>
#include <svx/TableStylesParser.hxx>
#include "scdllapi.h"
#include "zforauto.hxx"
#include <array>
#include <memory>
#include <map>
#include <climits>
#include "document.hxx"
class SfxItemSet;
class ScDocument;
/**
A binary blob of writer-specific data. This data typically consists of types that are
unavailable to Calc (e.g. SwFmtVertOrient), or that Calc doesn't care about.
@remarks Note that in autoformat versions prior to AUTOFORMAT_DATA_ID_31005, Calc
logic handled and stored several writer-specific items (such as ScAutoFormatDataField::aAdjust).
That logic was preserved. From _31005 onward, writer-specific data should be handled by
blobs to avoid needlessly complicating the Calc logic.
*/
struct AutoFormatSwBlob
class ScAutoFormatDataField : public SvxAutoFormatDataField
{
std::unique_ptr<sal_uInt8[]> pData;
std::size_t size;
AutoFormatSwBlob() : size(0)
{
}
AutoFormatSwBlob(const AutoFormatSwBlob&) = delete;
const AutoFormatSwBlob& operator=(const AutoFormatSwBlob&) = delete;
void Reset()
{
pData.reset();
size = 0;
}
};
/// Struct with version numbers of the Items
struct ScAfVersions : public AutoFormatVersions
{
private:
AutoFormatSwBlob swVersions;
public:
ScAfVersions();
void Load( SvStream& rStream, sal_uInt16 nVer );
void Write(SvStream& rStream, sal_uInt16 fileVersion);
};
/// Contains all items for one cell of a table autoformat.
class ScAutoFormatDataField : public AutoFormatBase
{
private:
AutoFormatSwBlob m_swFields;
// number format
ScNumFormatAbbrev aNumFormat;
public:
ScAutoFormatDataField();
ScAutoFormatDataField( const ScAutoFormatDataField& rCopy );
ScAutoFormatDataField(const ScAutoFormatDataField& rCopy);
ScAutoFormatDataField(const SvxAutoFormatDataField& rCopy);
~ScAutoFormatDataField();
// block assignment operator
ScAutoFormatDataField& operator=(const ScAutoFormatDataField& rRef) = delete;
// number format
const ScNumFormatAbbrev& GetNumFormat() const { return aNumFormat; }
// number format
void SetNumFormat( const ScNumFormatAbbrev& rNumFormat ) { aNumFormat = rNumFormat; }
bool Load( SvStream& rStream, const ScAfVersions& rVersions, sal_uInt16 nVer );
bool Save( SvStream& rStream, sal_uInt16 fileVersion );
};
class SAL_DLLPUBLIC_RTTI ScAutoFormatData
class SAL_DLLPUBLIC_RTTI ScAutoFormatData : public SvxAutoFormatData
{
private:
OUString aName;
sal_uInt16 nStrResId;
// common flags of Calc and Writer
bool bIncludeFont : 1;
bool bIncludeJustify : 1;
bool bIncludeFrame : 1;
bool bIncludeBackground : 1;
// Calc specific flags
bool bIncludeValueFormat : 1;
bool bIncludeWidthHeight : 1;
// Writer-specific data
AutoFormatSwBlob m_swFields;
std::array<std::unique_ptr<ScAutoFormatDataField>,16> ppDataField;
SAL_DLLPRIVATE ScAutoFormatDataField& GetField( sal_uInt16 nIndex );
SAL_DLLPRIVATE const ScAutoFormatDataField& GetField( sal_uInt16 nIndex ) const;
std::array<std::unique_ptr<ScAutoFormatDataField>, ELEMENT_COUNT> mpDataField;
public:
ScAutoFormatData();
SC_DLLPUBLIC ScAutoFormatData( const ScAutoFormatData& rData );
SC_DLLPUBLIC ~ScAutoFormatData();
SC_DLLPUBLIC ScAutoFormatData(const ScAutoFormatData& rData);
SC_DLLPUBLIC ScAutoFormatData(const SvxAutoFormatData& rData);
void SetName( const OUString& rName ) { aName = rName; nStrResId = USHRT_MAX; }
const OUString& GetName() const { return aName; }
ScAutoFormatDataField* GetField(size_t nIndex) override;
const ScAutoFormatDataField* GetField(size_t nIndex) const override;
bool SetField(size_t nIndex, const SvxAutoFormatDataField& aField) override;
SvxAutoFormatData* MakeCopy() const override { return new ScAutoFormatData(*this); };
SvxAutoFormatDataField* GetDefaultField() const override { return new ScAutoFormatDataField; };
bool GetIncludeValueFormat() const { return bIncludeValueFormat; }
bool GetIncludeFont() const { return bIncludeFont; }
bool GetIncludeJustify() const { return bIncludeJustify; }
bool GetIncludeFrame() const { return bIncludeFrame; }
bool GetIncludeBackground() const { return bIncludeBackground; }
bool GetIncludeWidthHeight() const { return bIncludeWidthHeight; }
void SetIncludeValueFormat( bool bValueFormat ) { bIncludeValueFormat = bValueFormat; }
void SetIncludeFont( bool bFont ) { bIncludeFont = bFont; }
void SetIncludeJustify( bool bJustify ) { bIncludeJustify = bJustify; }
void SetIncludeFrame( bool bFrame ) { bIncludeFrame = bFrame; }
void SetIncludeBackground( bool bBackground ) { bIncludeBackground = bBackground; }
void SetIncludeWidthHeight( bool bWidthHeight ) { bIncludeWidthHeight = bWidthHeight; }
const SfxPoolItem* GetItem( sal_uInt16 nIndex, sal_uInt16 nWhich ) const;
template<class T> const T* GetItem( sal_uInt16 nIndex, TypedWhichId<T> nWhich ) const
const SfxPoolItem* GetItem(sal_uInt8 nIndex, sal_uInt16 nWhich) const;
template <class T> const T* GetItem(sal_uInt8 nIndex, TypedWhichId<T> nWhich) const
{
return static_cast<const T*>(GetItem(nIndex, sal_uInt16(nWhich)));
}
void PutItem( sal_uInt16 nIndex, const SfxPoolItem& rItem );
void CopyItem( sal_uInt16 nToIndex, sal_uInt16 nFromIndex, sal_uInt16 nWhich );
void PutItem(size_t nIndex, const SfxPoolItem& rItem);
const ScNumFormatAbbrev& GetNumFormat( sal_uInt16 nIndex ) const;
bool HasSameData( sal_uInt16 nIndex1, sal_uInt16 nIndex2 ) const;
void FillToItemSet( sal_uInt16 nIndex, SfxItemSet& rItemSet, const ScDocument& rDoc ) const;
void GetFromItemSet( sal_uInt16 nIndex, const SfxItemSet& rItemSet, const ScNumFormatAbbrev& rNumFormat );
bool Load( SvStream& rStream, const ScAfVersions& rVersions );
bool Save( SvStream& rStream, sal_uInt16 fileVersion );
void CopyItem(size_t nToIndex, size_t nFromIndex, sal_uInt16 nWhich);
void FillToItemSet(size_t nIndex, SfxItemSet& rItemSet) const;
void GetFromItemSet(size_t nIndex, const SfxItemSet& rItemSet);
};
struct DefaultFirstEntry {
bool operator() (const OUString& left, const OUString& right) const;
};
class SAL_DLLPUBLIC_RTTI ScAutoFormat
class SAL_DLLPUBLIC_RTTI ScAutoFormat : public SvxAutoFormat
{
typedef std::map<OUString, std::unique_ptr<ScAutoFormatData>, DefaultFirstEntry> MapType;
MapType m_Data;
bool mbSaveLater;
ScAfVersions m_aVersions;
ScAutoFormat(const ScAutoFormat&) = delete;
const ScAutoFormat operator=(const ScAutoFormat&) = delete;
private:
struct Impl;
std::unique_ptr<Impl> mpImpl;
public:
typedef MapType::const_iterator const_iterator;
typedef MapType::iterator iterator;
ScAutoFormat();
void Load();
SC_DLLPUBLIC bool Save();
~ScAutoFormat();
void SetSaveLater( bool bSet );
bool IsSaveLater() const { return mbSaveLater; }
const ScAutoFormatData* findByIndex(size_t nIndex) const;
SC_DLLPUBLIC ScAutoFormatData* findByIndex(size_t nIndex);
SC_DLLPUBLIC iterator find(const OUString& rName);
SC_DLLPUBLIC iterator insert(std::unique_ptr<ScAutoFormatData> pNew);
SC_DLLPUBLIC void erase(const iterator& it);
SC_DLLPUBLIC size_t size() const;
const_iterator begin() const;
const_iterator end() const;
SC_DLLPUBLIC iterator begin();
SC_DLLPUBLIC iterator end();
const ScAutoFormatData* GetData(size_t nIndex) const override;
ScAutoFormatData* GetData(size_t nIndex) override;
bool InsertAutoFormat(SvxAutoFormatData* pFormat) override;
ScAutoFormatData* ReleaseAutoFormat(const OUString& rName) override;
ScAutoFormatData* FindAutoFormat(const OUString& rName) const override;
const ScAutoFormatData* GetResolvedStyle(const SvxAutoFormatData* pData) const override;
SvxAutoFormatData* GetDefaultData() override { return new ScAutoFormatData();};
SvxAutoFormatDataField* GetDefaultField() override { return new ScAutoFormatDataField; };
size_t size() const override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+1
View File
@@ -587,6 +587,7 @@ public:
SC_DLLPUBLIC static void SetSearchItem( const SvxSearchItem& rNew );
SC_DLLPUBLIC static ScAutoFormat* GetAutoFormat();
SC_DLLPUBLIC static ScAutoFormat* GetOrCreateAutoFormat();
SC_DLLPUBLIC static void ResetAutoFormat();
static void ClearAutoFormat(); //BugId 54209
static LegacyFuncCollection* GetLegacyFuncCollection();
SC_DLLPUBLIC static ScUnoAddInCollection* GetAddInCollection();
-1
View File
@@ -173,7 +173,6 @@
#include <scresid.hxx>
#include <scui_def.hxx>
#include <scuiasciiopt.hxx>
#include <scuiautofmt.hxx>
#include <scuiimoptdlg.hxx>
#include <scuitphfedit.hxx>
#include <shtabdlg.hxx>
-4
View File
@@ -421,10 +421,6 @@ public:
virtual VclPtr<AbstractScTextImportOptionsDlg> CreateScTextImportOptionsDlg(weld::Window* pParent) = 0;
virtual VclPtr<AbstractScAutoFormatDlg> CreateScAutoFormatDlg(weld::Window* pParent,
ScAutoFormat* pAutoFormat,
const ScAutoFormatData* pSelFormatData,
ScViewData& rViewData) = 0;
virtual VclPtr<AbstractScColRowLabelDlg> CreateScColRowLabelDlg (weld::Window* pParent,
bool bCol,
bool bRow) = 0;
+14 -22
View File
@@ -7,6 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <editeng/borderline.hxx>
#include <sal/config.h>
#include <helper/qahelper.hxx>
#include <sal/log.hxx>
@@ -719,7 +720,7 @@ CPPUNIT_TEST_FIXTURE(ScMacrosTest, testTdf107572)
u"TestModule"_ustr,
uno::Any(
u"Function Main\n"
" thisComponent.Sheets(0).getCellRangeByName(\"A1:F14\").autoformat(\"Default\")\n"
" thisComponent.Sheets(0).getCellRangeByName(\"A1:F14\").autoformat(\"Default Style\")\n"
"End Function\n"_ustr));
// Without the fix in place, this test would have crashed
@@ -727,29 +728,20 @@ CPPUNIT_TEST_FIXTURE(ScMacrosTest, testTdf107572)
ScDocument* pDoc = getScDoc();
//Check the autoformat has been applied
for (SCCOL i = 0; i < 5; ++i)
SCCOL startCol = 0, endCol = 4;
SCROW startRow = 0, endRow = 12;
// Check autoformat has benn applied
for (SCCOL col = startCol; col <= endCol; ++col)
{
const ScPatternAttr* pAttr = pDoc->GetPattern(i, 0, 0);
const SvxBrushItem& rBackground = pAttr->GetItem(ATTR_BACKGROUND);
const Color& rColor = rBackground.GetColor();
for (SCROW row = startRow; row <= endRow; ++row)
{
const ScPatternAttr* pAttr = pDoc->GetPattern(col, row, 0);
const SvxBoxItem& rBorder = pAttr->GetItem(ATTR_BORDER);
CPPUNIT_ASSERT_EQUAL(COL_BLUE, rColor);
}
for (SCROW i = 1; i < 13; ++i)
{
const ScPatternAttr* pAttr = pDoc->GetPattern(0, i, 0);
const SvxBrushItem& rBackground = pAttr->GetItem(ATTR_BACKGROUND);
const Color& rColor = rBackground.GetColor();
CPPUNIT_ASSERT_EQUAL(Color(0x4d, 0x4d, 0x4d), rColor);
const ScPatternAttr* pAttr2 = pDoc->GetPattern(5, i, 0);
const SvxBrushItem& rBackground2 = pAttr2->GetItem(ATTR_BACKGROUND);
const Color& rColor2 = rBackground2.GetColor();
CPPUNIT_ASSERT_EQUAL(COL_GRAY3, rColor2);
CPPUNIT_ASSERT_EQUAL(COL_BLACK, rBorder.GetTop()->GetColor());
CPPUNIT_ASSERT_EQUAL(COL_BLACK, rBorder.GetLeft()->GetColor());
}
}
}
+2 -3
View File
@@ -83,7 +83,7 @@ ScAutoFormatObj::ScAutoFormatObj()
: UnoApiTest(u"/sc/qa/extras/testdocuments"_ustr)
, XElementAccess(cppu::UnoType<beans::XPropertySet>::get())
, XIndexAccess(16)
, XNamed(u"Default"_ustr)
, XNamed(u"Simple List Shaded"_ustr) // The last table style in 'tablestyles.xml'
, XServiceInfo(u"ScAutoFormatObj"_ustr, u"com.sun.star.sheet.TableAutoFormat"_ustr)
{
}
@@ -96,8 +96,7 @@ uno::Reference<uno::XInterface> ScAutoFormatObj::init()
uno::Reference<container::XIndexAccess> xIA(
xMSF->createInstance(u"com.sun.star.sheet.TableAutoFormats"_ustr), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xTableAutoFormat(xIA->getByIndex(xIA->getCount() - 1),
uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xTableAutoFormat(xIA->getByIndex(10), uno::UNO_QUERY_THROW);
return xTableAutoFormat;
}
+2 -2
View File
@@ -83,8 +83,8 @@ public:
ScAutoFormatsObj::ScAutoFormatsObj()
: UnoApiTest(u"/sc/qa/extras/testdocuments"_ustr)
, XElementAccess(cppu::UnoType<container::XNamed>::get())
, XIndexAccess(2)
, XNameAccess(u"Default"_ustr)
, XIndexAccess(12) // There are 11 table styles by default, so (11 + 1)
, XNameAccess(u"Default Style"_ustr)
, XNameContainer(u"ScAutoFormatsObj"_ustr)
, XNameReplace(u"ScAutoFormatsObj"_ustr)
, XServiceInfo(u"stardiv.StarCalc.ScAutoFormatsObj"_ustr,
-5
View File
@@ -27,7 +27,6 @@ class autoFormat(UITestCase):
fontcb = xDialog.getChild("fontcb")
patterncb = xDialog.getChild("patterncb")
alignmentcb = xDialog.getChild("alignmentcb")
autofitcb = xDialog.getChild("autofitcb")
entry = formatlb.getChild("7") #Financial
entry.executeAction("SELECT", tuple())
@@ -36,7 +35,6 @@ class autoFormat(UITestCase):
fontcb.executeAction("CLICK", tuple())
patterncb.executeAction("CLICK", tuple())
alignmentcb.executeAction("CLICK", tuple())
autofitcb.executeAction("CLICK", tuple())
#verify
@@ -48,7 +46,6 @@ class autoFormat(UITestCase):
fontcb = xDialog.getChild("fontcb")
patterncb = xDialog.getChild("patterncb")
alignmentcb = xDialog.getChild("alignmentcb")
autofitcb = xDialog.getChild("autofitcb")
entry = formatlb.getChild("7") #Financial
entry.executeAction("SELECT", tuple())
@@ -57,13 +54,11 @@ class autoFormat(UITestCase):
self.assertEqual(get_state_as_dict(fontcb)["Selected"], "false")
self.assertEqual(get_state_as_dict(patterncb)["Selected"], "false")
self.assertEqual(get_state_as_dict(alignmentcb)["Selected"], "false")
self.assertEqual(get_state_as_dict(autofitcb)["Selected"], "false")
numformatcb.executeAction("CLICK", tuple())
bordercb.executeAction("CLICK", tuple())
fontcb.executeAction("CLICK", tuple())
patterncb.executeAction("CLICK", tuple())
alignmentcb.executeAction("CLICK", tuple())
autofitcb.executeAction("CLICK", tuple())
# vim: set shiftwidth=4 softtabstop=4 expandtab:
@@ -21,13 +21,13 @@ class tdf91726(UITestCase):
#AutoFormat Styles
with self.ui_test.execute_dialog_through_command(".uno:AutoFormat", close_button="") as xDialog:
#add new style "Default"
xadd = xDialog.getChild("add")
xadd = xDialog.getChild("rename")
# Use empty close_button to open consecutive dialogs
with self.ui_test.execute_blocking_action(
xadd.executeAction, args=('CLICK', ()), close_button="") as dialog:
nameEntry = dialog.getChild("name_entry")
nameEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"Default"}))
nameEntry = dialog.getChild("edit")
nameEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"Academic"}))
xOKBtn = dialog.getChild("ok")
with self.ui_test.execute_blocking_action(
@@ -39,9 +39,9 @@ class tdf91726(UITestCase):
with self.ui_test.execute_blocking_action(
xOKBtn2.executeAction, args=('CLICK', ()), close_button="cancel") as dialog3:
nameEntry = dialog3.getChild("name_entry")
nameEntry = dialog3.getChild("edit")
#back to name dialog, LO should not crash
self.assertEqual(get_state_as_dict(nameEntry)["Text"], "Default")
self.assertEqual(get_state_as_dict(nameEntry)["Text"], "Default Style")
xCanceltn = xDialog.getChild("cancel")
self.ui_test.close_dialog_through_button(xCanceltn)
File diff suppressed because it is too large Load Diff
+2 -5
View File
@@ -252,10 +252,6 @@ void ScGlobal::ClearAutoFormat()
assert(!bThreadedGroupCalcInProgress);
if (xAutoFormat)
{
// When modified via StarOne then only the SaveLater flag is set and no saving is done.
// If the flag is set then save now.
if (xAutoFormat->IsSaveLater())
xAutoFormat->Save();
xAutoFormat.reset();
}
}
@@ -271,12 +267,13 @@ ScAutoFormat* ScGlobal::GetOrCreateAutoFormat()
if ( !xAutoFormat )
{
xAutoFormat.reset(new ScAutoFormat);
xAutoFormat->Load();
}
return xAutoFormat.get();
}
void ScGlobal::ResetAutoFormat() { xAutoFormat.reset(new ScAutoFormat); }
LegacyFuncCollection* ScGlobal::GetLegacyFuncCollection()
{
return comphelper::doubleCheckedInit( pLegacyFuncCollection, []() { return new LegacyFuncCollection(); });
+33 -1
View File
@@ -18,6 +18,7 @@
*/
#include <editeng/boxitem.hxx>
#include <svl/itemset.hxx>
#include <poolcach.hxx>
#include <tools/debug.hxx>
@@ -68,7 +69,38 @@ const CellAttributeHolder& ScItemPoolCache::ApplyTo(const CellAttributeHolder& r
}
else
{
pNewItem->GetItemSetWritable().Put(*pSetToPut);
// We preserve original cell's border formatting
if (pSetToPut->GetItemState(ATTR_BORDER, false) == SfxItemState::SET)
{
if (const SvxBoxItem* pOldBox = pAttr->GetItemSet().GetItemIfSet(ATTR_BORDER))
{
SvxBoxItem aNewBox(pSetToPut->Get(ATTR_BORDER));
if (!aNewBox.GetTop())
aNewBox.SetLine(pOldBox->GetTop(), SvxBoxItemLine::TOP);
if (!aNewBox.GetBottom())
aNewBox.SetLine(pOldBox->GetBottom(), SvxBoxItemLine::BOTTOM);
if (!aNewBox.GetLeft())
aNewBox.SetLine(pOldBox->GetLeft(), SvxBoxItemLine::LEFT);
if (!aNewBox.GetRight())
aNewBox.SetLine(pOldBox->GetRight(), SvxBoxItemLine::RIGHT);
if (!aNewBox.GetDistance(SvxBoxItemLine::RIGHT))
aNewBox.SetAllDistances(pOldBox->GetDistance(SvxBoxItemLine::RIGHT));
// Adding the merged border properties to new cell
pNewItem->GetItemSetWritable().Put(aNewBox);
// Remove existing cell's border formatting
SfxItemSet aSet(*pSetToPut);
aSet.ClearItem(ATTR_BORDER);
// Adding remaining properties
pNewItem->GetItemSetWritable().Put(aSet);
}
else
pNewItem->GetItemSetWritable().Put(*pSetToPut);
}
else
pNewItem->GetItemSetWritable().Put(*pSetToPut);
}
m_aCache.emplace_back(rOrigItem, CellAttributeHolder(pNewItem, true));
+84 -200
View File
@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <svx/svxtableitems.hxx>
#include <svx/TableAutoFmt.hxx>
#include <scitems.hxx>
#include <comphelper/string.hxx>
#include <editeng/boxitem.hxx>
@@ -56,6 +58,8 @@
#include <list>
#include <string_view>
using namespace Autoformat;
#define D_MAX_LONG_ double(0x7fffffff)
namespace {
@@ -2673,7 +2677,7 @@ void ScTable::AutoFormatArea(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SC
const ScPatternAttr& rAttr, sal_uInt16 nFormatNo)
{
ScAutoFormat& rFormat = *ScGlobal::GetOrCreateAutoFormat();
ScAutoFormatData* pData = rFormat.findByIndex(nFormatNo);
ScAutoFormatData* pData = rFormat.GetData(nFormatNo);
if (pData)
{
ApplyPatternArea(nStartCol, nStartRow, nEndCol, nEndRow, rAttr);
@@ -2687,228 +2691,108 @@ void ScTable::AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW
return;
ScAutoFormat& rFormat = *ScGlobal::GetOrCreateAutoFormat();
ScAutoFormatData* pData = rFormat.findByIndex(nFormatNo);
const ScAutoFormatData* pData = rFormat.GetResolvedStyle(rFormat.GetData(nFormatNo));
if (!pData)
return;
std::unique_ptr<ScPatternAttr> pPatternAttrs[16];
for (sal_uInt8 i = 0; i < 16; ++i)
std::unique_ptr<ScPatternAttr> pPatternAttrs[ELEMENT_COUNT];
for (sal_uInt8 i = 0; i < ELEMENT_COUNT; ++i)
{
pPatternAttrs[i].reset(new ScPatternAttr(rDocument.getCellAttributeHelper()));
pData->FillToItemSet(i, pPatternAttrs[i]->GetItemSetWritable(), rDocument);
pData->FillToItemSet(i, pPatternAttrs[i]->GetItemSetWritable());
}
// Important special case: when the whole rows are selected. Then applying autoformat to right
// column individually would create all columns. In this case, assume that right column isn't
// needed, to allow "to the end of row" format optimization (which doesn't create columns).
// Keep left column in this case, because it may be pre-formatted for categories. To enable the
// optimization, apply uniform format row by row where possible, not column by column.
// Reset cell autoformat before applying new one
DeleteArea(nStartCol, nStartRow, nEndCol, nEndRow, InsertDeleteFlags::ATTRIB);
const bool isWholeRows = nStartCol == 0 && nEndCol == rDocument.MaxCol();
AutoFormatArea(nStartCol, nStartRow, nEndCol, nEndRow, *pPatternAttrs[BACKGROUND], nFormatNo);
AutoFormatArea(nStartCol, nStartRow, nEndCol, nEndRow, *pPatternAttrs[BODY], nFormatNo);
////////////////////////////////////////////////////////////////////////////////////////////////
// Top row data indexes:
// 0 - left corner style
// 1 - odd columns style
// 2 - even column style
// 3 - right corner style
////////////////////////////////////////////////////////////////////////////////////////////////
SCCOL startOffset = 1;
// Left top corner
if (pData->HasSameData(0, 1) && pData->HasSameData(0, 2))
startOffset = 0; // Left corner is same as the rest of the row
else
AutoFormatArea(nStartCol, nStartRow, nStartCol, nStartRow, *pPatternAttrs[0], nFormatNo);
SCCOL endOffset = 1;
// Right top corner: ignore when whole rows selected
if (isWholeRows || (pData->HasSameData(3, 1) && pData->HasSameData(3, 2)))
endOffset = 0; // Right corner is same as the rest of the row (most important case)
else
AutoFormatArea(nEndCol, nStartRow, nEndCol, nStartRow, *pPatternAttrs[3], nFormatNo);
// Top row
if (pData->HasSameData(1, 2))
AutoFormatArea(nStartCol + startOffset, nStartRow, nEndCol - endOffset, nStartRow, *pPatternAttrs[1], nFormatNo);
else
{
sal_uInt16 nIndex = 1;
for (SCCOL nCol = nStartCol + startOffset; nCol <= nEndCol - endOffset; nCol++)
{
AutoFormatArea(nCol, nStartRow, nCol, nStartRow, *pPatternAttrs[nIndex], nFormatNo);
if (nIndex == 1)
nIndex = 2;
else
nIndex = 1;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
// Body data indexes:
// 4 - left column odd row style
// 8 - left column even row style
// 7 - right column odd row style
// 11 - right column even row style
// 5 - body odd column odd row style
// 6 - body even column odd row style
// 9 - body odd column even row style
// 10 - body even column even row style
////////////////////////////////////////////////////////////////////////////////////////////////
startOffset = 1;
// Left column
if (pData->HasSameData(4, 5) && pData->HasSameData(4, 6) && pData->HasSameData(8, 9) && pData->HasSameData(8, 10))
startOffset = 0; // Left column is same as the lines of the body
else
{
if (pData->HasSameData(4, 8)) // even and odd rows are same
AutoFormatArea(nStartCol, nStartRow + 1, nStartCol, nEndRow - 1, *pPatternAttrs[4], nFormatNo);
else
{
sal_uInt16 nIndex = 4;
for (SCROW nRow = nStartRow + 1; nRow < nEndRow; nRow++)
{
AutoFormatArea(nStartCol, nRow, nStartCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
if (nIndex == 4)
nIndex = 8;
else
nIndex = 4;
}
}
}
endOffset = 1;
// Right column: ignore when whole rows selected
if (isWholeRows || (pData->HasSameData(7, 5) && pData->HasSameData(7, 6) && pData->HasSameData(11, 9) && pData->HasSameData(11, 10)))
endOffset = 0; // Right column is same as the lines of the body (most important case)
else
{
if (pData->HasSameData(7, 11)) // even and odd rows are same
AutoFormatArea(nEndCol, nStartRow + 1, nEndCol, nEndRow - 1, *pPatternAttrs[7], nFormatNo);
else
{
sal_uInt16 nIndex = 7;
for (SCROW nRow = nStartRow + 1; nRow < nEndRow; nRow++)
{
AutoFormatArea(nEndCol, nRow, nEndCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
if (nIndex == 7)
nIndex = 11;
else
nIndex = 7;
}
}
}
// Body
if (pData->HasSameData(5, 6) && pData->HasSameData(9, 10)) // Odd and even columns are same (most important case)
{
if (pData->HasSameData(5, 9)) // Everything is the same
AutoFormatArea(nStartCol + startOffset, nStartRow + 1, nEndCol - endOffset, nEndRow - 1, *pPatternAttrs[5], nFormatNo);
else // Odd and even rows differ
{
if (pProgress)
pProgress->SetState(1, nEndRow - nStartRow + 3); // account for elements outside the "Body" block
sal_uInt16 nIndex = 5;
for (SCROW nRow = nStartRow + 1; nRow < nEndRow; nRow++)
{
AutoFormatArea(nStartCol + startOffset, nRow, nEndCol - endOffset, nRow, *pPatternAttrs[nIndex], nFormatNo);
if (nIndex == 5)
nIndex = 9;
else
nIndex = 5;
if (pProgress)
pProgress->SetStateOnPercent(nRow - nStartRow + 1);
}
}
}
else if (pData->HasSameData(5, 9) && pData->HasSameData(6, 10)) // odd and even rows are same
sal_uInt8 nIndex = ODD_COL;
if (pData->UseBandedColStyles())
{
if (pProgress)
pProgress->SetState(1, nEndCol - nStartCol + 3); // account for elements outside the "Body" block
sal_uInt16 nIndex = 5;
for (SCCOL nCol = nStartCol + startOffset; nCol <= nEndCol - endOffset; nCol++)
pProgress->SetState(1, nEndCol - nStartCol);
for (SCROW nCol = nStartCol; nCol <= nEndCol; nCol++)
{
AutoFormatArea(nCol, nStartRow + 1, nCol, nEndRow - 1, *pPatternAttrs[nIndex], nFormatNo);
if (nIndex == 5)
nIndex = 6;
else
nIndex = 5;
AutoFormatArea(nCol, nStartRow, nCol, nEndRow, *pPatternAttrs[nIndex], nFormatNo);
nIndex = nIndex == ODD_COL ? EVEN_COL : ODD_COL;
if (pProgress)
pProgress->SetStateOnPercent(nCol - nStartCol + 1);
pProgress->SetStateOnPercent(nCol - nStartCol);
}
}
else // Everything is different
if (pData->UseBandedRowStyles())
{
nIndex = ODD_ROW;
if (pProgress)
pProgress->SetState(1, nEndCol - nStartCol + 3); // account for elements outside the "Body" block
sal_uInt16 nIndex = 5;
for (SCCOL nCol = nStartCol + startOffset; nCol <= nEndCol - endOffset; nCol++)
pProgress->SetState(1, nEndRow - nStartRow);
for (SCROW nRow = nStartRow; nRow <= nEndRow; nRow++)
{
for (SCROW nRow = nStartRow + 1; nRow < nEndRow; nRow++)
{
AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
if ((nIndex == 5) || (nIndex == 9))
{
if (nIndex == 5)
nIndex = 9;
else
nIndex = 5;
}
else
{
if (nIndex == 6)
nIndex = 10;
else
nIndex = 6;
}
} // for nRow
if ((nIndex == 5) || (nIndex == 9))
nIndex = 6;
else
nIndex = 5;
AutoFormatArea(nStartCol, nRow, nEndCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
nIndex = nIndex == ODD_ROW ? EVEN_ROW : ODD_ROW;
if (pProgress)
pProgress->SetStateOnPercent(nCol - nStartCol + 1);
pProgress->SetStateOnPercent(nRow - nStartCol);
}
}
} // for nCol
} // if not all equal
////////////////////////////////////////////////////////////////////////////////////////////////
// Bottom row data indexes:
// 12 - left corner style
// 13 - odd columns style
// 14 - even column style
// 15 - right corner style
////////////////////////////////////////////////////////////////////////////////////////////////
startOffset = 1;
// Left bottom corner
if (pData->HasSameData(12, 13) && pData->HasSameData(12, 14))
startOffset = 0;
else
AutoFormatArea(nStartCol, nEndRow, nStartCol, nEndRow, *pPatternAttrs[12], nFormatNo);
endOffset = 1;
// Right bottom corner: ignore when whole rows selected
if (isWholeRows || (pData->HasSameData(15, 13) && pData->HasSameData(15, 14)))
endOffset = 0;
else
AutoFormatArea(nEndCol, nEndRow, nEndCol, nEndRow, *pPatternAttrs[15], nFormatNo);
// Bottom row
if (pData->HasSameData(13, 14))
AutoFormatArea(nStartCol + startOffset, nEndRow, nEndCol - endOffset, nEndRow, *pPatternAttrs[13], nFormatNo);
else
if (pData->UseLastColStyles())
{
sal_uInt16 nIndex = 13;
for (SCCOL nCol = nStartCol + startOffset; nCol <= nEndCol - endOffset; nCol++)
nIndex = LAST_COL;
for (SCROW nRow = nStartRow; nRow <= nEndRow; nRow++)
{
AutoFormatArea(nEndCol, nRow, nEndCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
}
}
if (pData->UseFirstColStyles())
{
nIndex = FIRST_COL;
for (SCROW nRow = nStartRow; nRow <= nEndRow; nRow++)
{
AutoFormatArea(nStartCol, nRow, nStartCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
}
}
if (pData->UseLastRowStyles())
{
nIndex = LAST_ROW;
for (SCROW nCol = nStartCol; nCol <= nEndCol; nCol++)
{
AutoFormatArea(nCol, nEndRow, nCol, nEndRow, *pPatternAttrs[nIndex], nFormatNo);
if (nIndex == 13)
nIndex = 14;
else
nIndex = 13;
}
nIndex = LAST_ROW_EVEN_COL;
for (SCROW nCol = nStartCol + 1; nCol <= nEndCol; nCol += 2)
{
AutoFormatArea(nCol, nEndRow, nCol, nEndRow, *pPatternAttrs[nIndex], nFormatNo);
}
nIndex = LAST_ROW_END_COL;
AutoFormatArea(nEndCol, nEndRow, nEndCol, nEndRow, *pPatternAttrs[nIndex], nFormatNo);
nIndex = LAST_ROW_START_COL;
AutoFormatArea(nStartCol, nEndRow, nStartCol, nEndRow, *pPatternAttrs[nIndex], nFormatNo);
}
if (pData->UseFirstRowStyles())
{
nIndex = FIRST_ROW;
for (SCROW nCol = nStartCol; nCol <= nEndCol; nCol++)
{
AutoFormatArea(nCol, nStartRow, nCol, nStartRow, *pPatternAttrs[nIndex], nFormatNo);
}
nIndex = FIRST_ROW_EVEN_COL;
for (SCROW nCol = nStartCol + 1; nCol <= nEndCol; nCol += 2)
{
AutoFormatArea(nCol, nStartRow, nCol, nStartRow, *pPatternAttrs[nIndex], nFormatNo);
}
nIndex = FIRST_ROW_END_COL;
AutoFormatArea(nEndCol, nStartRow, nEndCol, nStartRow, *pPatternAttrs[nIndex], nFormatNo);
nIndex = FIRST_ROW_START_COL;
AutoFormatArea(nStartCol, nStartRow, nStartCol, nStartRow, *pPatternAttrs[nIndex],
nFormatNo);
}
}
@@ -2916,7 +2800,7 @@ void ScTable::GetAutoFormatAttr(SCCOL nCol, SCROW nRow, sal_uInt16 nIndex, ScAut
{
sal_uInt32 nFormatIndex = GetNumberFormat( nCol, nRow );
ScNumFormatAbbrev aNumFormat( nFormatIndex, *rDocument.GetFormatTable() );
rData.GetFromItemSet( nIndex, GetPattern( nCol, nRow )->GetItemSet(), aNumFormat );
rData.GetFromItemSet( nIndex, GetPattern( nCol, nRow )->GetItemSet());
}
#define LF_LEFT 1
File diff suppressed because it is too large Load Diff
-21
View File
@@ -22,7 +22,6 @@
#include "scdlgfact.hxx"
#include <scuiasciiopt.hxx>
#include <scuiautofmt.hxx>
#include <corodlg.hxx>
#include <dapidata.hxx>
#include <dapitype.hxx>
@@ -139,26 +138,6 @@ VclPtr<AbstractScTextImportOptionsDlg> ScAbstractDialogFactory_Impl::CreateScTex
return VclPtr<AbstractScTextImportOptionsDlg_Impl>::Create(pParent);
}
namespace
{
class AbstractScAutoFormatDlg_Impl
: public vcl::AbstractDialogImpl_Sync<AbstractScAutoFormatDlg, ScAutoFormatDlg>
{
public:
using AbstractDialogImpl_BASE::AbstractDialogImpl_BASE;
sal_uInt16 GetIndex() const override { return m_pDlg->GetIndex(); }
OUString GetCurrFormatName() override { return m_pDlg->GetCurrFormatName(); }
};
}
VclPtr<AbstractScAutoFormatDlg> ScAbstractDialogFactory_Impl::CreateScAutoFormatDlg(weld::Window* pParent,
ScAutoFormat* pAutoFormat,
const ScAutoFormatData* pSelFormatData,
ScViewData& rViewData)
{
return VclPtr<AbstractScAutoFormatDlg_Impl>::Create(pParent, pAutoFormat, pSelFormatData, rViewData);
}
namespace
{
class AbstractScColRowLabelDlg_Impl
-4
View File
@@ -34,10 +34,6 @@ public:
virtual VclPtr<AbstractScTextImportOptionsDlg> CreateScTextImportOptionsDlg(weld::Window* pParent) override;
virtual VclPtr<AbstractScAutoFormatDlg> CreateScAutoFormatDlg(weld::Window* pParent,
ScAutoFormat* pAutoFormat,
const ScAutoFormatData* pSelFormatData,
ScViewData& rViewData) override;
virtual VclPtr<AbstractScColRowLabelDlg> CreateScColRowLabelDlg (weld::Window* pParent,
bool bCol,
bool bRow) override;
+2 -1
View File
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <svx/TableAutoFmt.hxx>
#include <scitems.hxx>
#include <comphelper/lok.hxx>
@@ -4326,7 +4327,7 @@ bool ScDocFunc::AutoFormat( const ScRange& rRange, const ScMarkData* pTabMark,
{
weld::WaitObject aWait( ScDocShell::GetActiveDialogParent() );
bool bSize = pAutoFormat->findByIndex(nFormatNo)->GetIncludeWidthHeight();
bool bSize = pAutoFormat->GetData(nFormatNo)->IsWidthHeight();
if (sal_uInt64(nEndCol - nStartCol + 1) * sal_uInt64(nEndRow - nStartRow + 1) > AUTOFORMAT_WARN_SIZE)
{
std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(ScDocShell::GetActiveDialogParent(),
-92
View File
@@ -1,92 +0,0 @@
/* -*- 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 <svx/framelinkarray.hxx>
#include <scdllapi.h>
#include <vcl/vclptr.hxx>
#include <vcl/weld/customweld.hxx>
namespace com::sun::star::i18n { class XBreakIterator; }
class ScAutoFormatData;
class SvxBoxItem;
class SvxLineItem;
class SvNumberFormatter;
class VirtualDevice;
class ScViewData;
class SC_DLLPUBLIC ScAutoFmtPreview : public weld::CustomWidgetController
{
public:
ScAutoFmtPreview();
void DetectRTL(const ScViewData& rViewData);
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
virtual ~ScAutoFmtPreview() override;
void NotifyChange( ScAutoFormatData* pNewData );
protected:
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
virtual void Resize() override;
private:
ScAutoFormatData* pCurData;
ScopedVclPtrInstance<VirtualDevice> aVD;
css::uno::Reference<css::i18n::XBreakIterator> xBreakIter;
bool bFitWidth;
svx::frame::Array maArray; /// Implementation to draw the frame borders.
bool mbRTL;
Size aPrvSize;
tools::Long mnLabelColWidth;
tools::Long mnDataColWidth1;
tools::Long mnDataColWidth2;
tools::Long mnRowHeight;
const OUString aStrJan;
const OUString aStrFeb;
const OUString aStrMar;
const OUString aStrNorth;
const OUString aStrMid;
const OUString aStrSouth;
const OUString aStrSum;
std::unique_ptr<SvNumberFormatter> pNumFmt;
SAL_DLLPRIVATE void Init();
SAL_DLLPRIVATE void DoPaint(vcl::RenderContext& rRenderContext);
SAL_DLLPRIVATE void CalcCellArray(bool bFitWidth);
SAL_DLLPRIVATE void CalcLineMap();
SAL_DLLPRIVATE void PaintCells(vcl::RenderContext& rRenderContext);
/* Usage of type size_t instead of SCCOL/SCROW is correct here - used in
conjunction with class svx::frame::Array (svx/framelinkarray.hxx), which
expects size_t coordinates. */
SAL_DLLPRIVATE sal_uInt16 GetFormatIndex( size_t nCol, size_t nRow ) const;
SAL_DLLPRIVATE const SvxBoxItem& GetBoxItem( size_t nCol, size_t nRow ) const;
SAL_DLLPRIVATE const SvxLineItem& GetDiagItem( size_t nCol, size_t nRow, bool bTLBR ) const;
SAL_DLLPRIVATE void DrawString(vcl::RenderContext& rRenderContext, size_t nCol, size_t nRow);
SAL_DLLPRIVATE void DrawBackground(vcl::RenderContext& rRenderContext);
SAL_DLLPRIVATE void MakeFonts(vcl::RenderContext const& rRenderContext, sal_uInt16 nIndex,
vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-80
View File
@@ -1,80 +0,0 @@
/* -*- 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 <vcl/weld/DialogController.hxx>
#include <vcl/weld/TreeView.hxx>
#include <vcl/weld/customweld.hxx>
#include <autoform.hxx>
#include "autofmt.hxx"
class ScAutoFormatDlg : public weld::GenericDialogController
{
public:
ScAutoFormatDlg(weld::Window* pParent,
ScAutoFormat* pAutoFormat,
const ScAutoFormatData* pSelFormatData,
const ScViewData& rViewData);
virtual ~ScAutoFormatDlg() override;
sal_uInt16 GetIndex() const { return m_nIndex; }
OUString GetCurrFormatName();
private:
OUString aStrTitle;
OUString aStrLabel;
OUString aStrClose;
OUString aStrDelMsg;
OUString aStrRename;
ScAutoFormat* pFormat;
const ScAutoFormatData* pSelFmtData;
sal_uInt16 m_nIndex;
bool bCoreDataChanged;
bool bFmtInserted;
ScAutoFmtPreview m_aWndPreview;
std::unique_ptr<weld::TreeView> m_xLbFormat;
std::unique_ptr<weld::Button> m_xBtnOk;
std::unique_ptr<weld::Button> m_xBtnCancel;
std::unique_ptr<weld::Button> m_xBtnAdd;
std::unique_ptr<weld::Button> m_xBtnRemove;
std::unique_ptr<weld::Button> m_xBtnRename;
std::unique_ptr<weld::CheckButton> m_xBtnNumFormat;
std::unique_ptr<weld::CheckButton> m_xBtnBorder;
std::unique_ptr<weld::CheckButton> m_xBtnFont;
std::unique_ptr<weld::CheckButton> m_xBtnPattern;
std::unique_ptr<weld::CheckButton> m_xBtnAlignment;
std::unique_ptr<weld::CheckButton> m_xBtnAdjust;
std::unique_ptr<weld::CustomWeld> m_xWndPreview;
void Init ();
void UpdateChecks ();
DECL_LINK( CheckHdl, weld::Toggleable&, void );
DECL_LINK( AddHdl, weld::Button&, void );
DECL_LINK( RemoveHdl, weld::Button&, void );
DECL_LINK( SelFmtHdl, weld::TreeView&, void );
DECL_LINK( CloseHdl, weld::Button&, void );
DECL_LINK( DblClkHdl, weld::TreeView&, bool );
DECL_LINK( RenameHdl, weld::Button&, void );
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-532
View File
@@ -1,532 +0,0 @@
/* -*- 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 .
*/
#include <scitems.hxx>
#include <editeng/boxitem.hxx>
#include <editeng/brushitem.hxx>
#include <editeng/contouritem.hxx>
#include <editeng/colritem.hxx>
#include <editeng/crossedoutitem.hxx>
#include <editeng/fontitem.hxx>
#include <editeng/justifyitem.hxx>
#include <editeng/lineitem.hxx>
#include <editeng/postitem.hxx>
#include <editeng/shdditem.hxx>
#include <editeng/udlnitem.hxx>
#include <editeng/wghtitem.hxx>
#include <o3tl/unit_conversion.hxx>
#include <osl/diagnose.h>
#include <svl/numformat.hxx>
#include <svtools/scriptedtext.hxx>
#include <svx/framelink.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
#include <vcl/virdev.hxx>
#include <comphelper/processfactory.hxx>
#include <drawinglayer/processor2d/processor2dtools.hxx>
#include <drawinglayer/processor2d/baseprocessor2d.hxx>
#include <strings.hrc>
#include <zforauto.hxx>
#include <global.hxx>
#include <autoform.hxx>
#include <autofmt.hxx>
#include <scresid.hxx>
#include <document.hxx>
#include <viewdata.hxx>
#include <svtools/colorcfg.hxx>
#include <scmod.hxx>
#define FRAME_OFFSET 4
// ScAutoFmtPreview
ScAutoFmtPreview::ScAutoFmtPreview()
: pCurData(nullptr)
, bFitWidth(false)
, mbRTL(false)
, aStrJan(ScResId(STR_JAN))
, aStrFeb(ScResId(STR_FEB))
, aStrMar(ScResId(STR_MAR))
, aStrNorth(ScResId(STR_NORTH))
, aStrMid(ScResId(STR_MID))
, aStrSouth(ScResId(STR_SOUTH))
, aStrSum(ScResId(STR_SUM))
, pNumFmt(new SvNumberFormatter(::comphelper::getProcessComponentContext(), ScGlobal::eLnge))
{
Init();
}
void ScAutoFmtPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
{
aVD.disposeAndReset(VclPtr<VirtualDevice>::Create(pDrawingArea->get_ref_device()));
CustomWidgetController::SetDrawingArea(pDrawingArea);
}
void ScAutoFmtPreview::Resize()
{
Size aSize(GetOutputSizePixel());
aPrvSize = Size(aSize.Width() - 6, aSize.Height() - 30);
mnLabelColWidth = (aPrvSize.Width() - 4) / 4 - 12;
mnDataColWidth1 = (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 3;
mnDataColWidth2 = (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 4;
mnRowHeight = (aPrvSize.Height() - 4) / 5;
NotifyChange(pCurData);
}
ScAutoFmtPreview::~ScAutoFmtPreview()
{
}
static void lcl_SetFontProperties(
vcl::Font& rFont,
const SvxFontItem& rFontItem,
const SvxWeightItem& rWeightItem,
const SvxPostureItem& rPostureItem )
{
rFont.SetFamily ( rFontItem.GetFamily() );
rFont.SetFamilyName ( rFontItem.GetFamilyName() );
rFont.SetStyleName ( rFontItem.GetStyleName() );
rFont.SetCharSet ( rFontItem.GetCharSet() );
rFont.SetPitch ( rFontItem.GetPitch() );
rFont.SetWeight ( rWeightItem.GetValue() );
rFont.SetItalic ( rPostureItem.GetValue() );
}
void ScAutoFmtPreview::MakeFonts(vcl::RenderContext const& rRenderContext, sal_uInt16 nIndex, vcl::Font& rFont, vcl::Font& rCJKFont, vcl::Font& rCTLFont)
{
if ( !pCurData )
return;
rFont = rCJKFont = rCTLFont = rRenderContext.GetFont();
Size aFontSize(rFont.GetFontSize().Width(), 10 * rRenderContext.GetDPIScaleFactor());
const SvxFontItem* pFontItem = pCurData->GetItem( nIndex, ATTR_FONT );
const SvxWeightItem* pWeightItem = pCurData->GetItem( nIndex, ATTR_FONT_WEIGHT );
const SvxPostureItem* pPostureItem = pCurData->GetItem( nIndex, ATTR_FONT_POSTURE );
const SvxFontItem* pCJKFontItem = pCurData->GetItem( nIndex, ATTR_CJK_FONT );
const SvxWeightItem* pCJKWeightItem = pCurData->GetItem( nIndex, ATTR_CJK_FONT_WEIGHT );
const SvxPostureItem* pCJKPostureItem = pCurData->GetItem( nIndex, ATTR_CJK_FONT_POSTURE );
const SvxFontItem* pCTLFontItem = pCurData->GetItem( nIndex, ATTR_CTL_FONT );
const SvxWeightItem* pCTLWeightItem = pCurData->GetItem( nIndex, ATTR_CTL_FONT_WEIGHT );
const SvxPostureItem* pCTLPostureItem = pCurData->GetItem( nIndex, ATTR_CTL_FONT_POSTURE );
const SvxUnderlineItem* pUnderlineItem = pCurData->GetItem( nIndex, ATTR_FONT_UNDERLINE );
const SvxOverlineItem* pOverlineItem = pCurData->GetItem( nIndex, ATTR_FONT_OVERLINE );
const SvxCrossedOutItem* pCrossedOutItem = pCurData->GetItem( nIndex, ATTR_FONT_CROSSEDOUT );
const SvxContourItem* pContourItem = pCurData->GetItem( nIndex, ATTR_FONT_CONTOUR );
const SvxShadowedItem* pShadowedItem = pCurData->GetItem( nIndex, ATTR_FONT_SHADOWED );
const SvxColorItem* pColorItem = pCurData->GetItem( nIndex, ATTR_FONT_COLOR );
lcl_SetFontProperties( rFont, *pFontItem, *pWeightItem, *pPostureItem );
lcl_SetFontProperties( rCJKFont, *pCJKFontItem, *pCJKWeightItem, *pCJKPostureItem );
lcl_SetFontProperties( rCTLFont, *pCTLFontItem, *pCTLWeightItem, *pCTLPostureItem );
Color aColor( pColorItem->GetValue() );
if( aColor == COL_TRANSPARENT )
aColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor();
#define SETONALLFONTS( MethodName, Value ) \
rFont.MethodName( Value ); rCJKFont.MethodName( Value ); rCTLFont.MethodName( Value );
SETONALLFONTS( SetUnderline, pUnderlineItem->GetValue() )
SETONALLFONTS( SetOverline, pOverlineItem->GetValue() )
SETONALLFONTS( SetStrikeout, pCrossedOutItem->GetValue() )
SETONALLFONTS( SetOutline, pContourItem->GetValue() )
SETONALLFONTS( SetShadow, pShadowedItem->GetValue() )
SETONALLFONTS( SetColor, aColor )
SETONALLFONTS( SetFontSize, aFontSize )
SETONALLFONTS( SetTransparent, true )
#undef SETONALLFONTS
}
sal_uInt16 ScAutoFmtPreview::GetFormatIndex( size_t nCol, size_t nRow ) const
{
static const sal_uInt16 pnFmtMap[] =
{
0, 1, 2, 1, 3,
4, 5, 6, 5, 7,
8, 9, 10, 9, 11,
4, 5, 6, 5, 7,
12, 13, 14, 13, 15
};
return pnFmtMap[ maArray.GetCellIndex( nCol, nRow, mbRTL ) ];
}
const SvxBoxItem& ScAutoFmtPreview::GetBoxItem( size_t nCol, size_t nRow ) const
{
assert(pCurData && "ScAutoFmtPreview::GetBoxItem - no format data found");
return * pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BORDER );
}
const SvxLineItem& ScAutoFmtPreview::GetDiagItem( size_t nCol, size_t nRow, bool bTLBR ) const
{
assert(pCurData && "ScAutoFmtPreview::GetDiagItem - no format data found");
return * pCurData->GetItem( GetFormatIndex( nCol, nRow ), bTLBR ? ATTR_BORDER_TLBR : ATTR_BORDER_BLTR );
}
void ScAutoFmtPreview::DrawString(vcl::RenderContext& rRenderContext, size_t nCol, size_t nRow)
{
if (!pCurData)
{
return;
}
// Emit the cell text
OUString cellString;
bool bNumFormat = pCurData->GetIncludeValueFormat();
sal_uInt32 nNum;
double nVal;
const Color* pDummy = nullptr;
sal_uInt16 nIndex = static_cast<sal_uInt16>(maArray.GetCellIndex(nCol, nRow, mbRTL));
switch (nIndex)
{
case 1: cellString = aStrJan; break;
case 2: cellString = aStrFeb; break;
case 3: cellString = aStrMar; break;
case 5: cellString = aStrNorth; break;
case 10: cellString = aStrMid; break;
case 15: cellString = aStrSouth; break;
case 4:
case 20: cellString = aStrSum; break;
case 6:
case 8:
case 16:
case 18: nVal = nIndex;
nNum = 5;
goto mknum;
case 17:
case 7: nVal = nIndex;
nNum = 6;
goto mknum;
case 11:
case 12:
case 13: nVal = nIndex;
nNum = 12 == nIndex ? 10 : 9;
goto mknum;
case 9: nVal = 21; nNum = 7; goto mknum;
case 14: nVal = 36; nNum = 11; goto mknum;
case 19: nVal = 51; nNum = 7; goto mknum;
case 21: nVal = 33; nNum = 13; goto mknum;
case 22: nVal = 36; nNum = 14; goto mknum;
case 23: nVal = 39; nNum = 13; goto mknum;
case 24: nVal = 108; nNum = 15;
mknum:
if (bNumFormat)
{
ScNumFormatAbbrev& rNumFormat = const_cast<ScNumFormatAbbrev&>(pCurData->GetNumFormat(sal_uInt16(nNum)));
nNum = rNumFormat.GetFormatIndex(*pNumFmt);
}
else
nNum = 0;
pNumFmt->GetOutputString(nVal, nNum, cellString, &pDummy);
break;
}
if (cellString.isEmpty())
return;
Size aStrSize;
sal_uInt16 nFmtIndex = GetFormatIndex( nCol, nRow );
const basegfx::B2DRange cellRange(maArray.GetCellRange( nCol, nRow ));
Point aPos(basegfx::fround<tools::Long>(cellRange.getMinX()), basegfx::fround<tools::Long>(cellRange.getMinY()));
sal_uInt16 nRightX = 0;
bool bJustify = pCurData->GetIncludeJustify();
SvxCellHorJustify eJustification;
SvtScriptedTextHelper aScriptedText(rRenderContext);
// Justification:
eJustification = mbRTL ? SvxCellHorJustify::Right : bJustify ?
pCurData->GetItem(nFmtIndex, ATTR_HOR_JUSTIFY)->GetValue() :
SvxCellHorJustify::Standard;
if (pCurData->GetIncludeFont())
{
vcl::Font aFont, aCJKFont, aCTLFont;
Size theMaxStrSize;
MakeFonts(rRenderContext, nFmtIndex, aFont, aCJKFont, aCTLFont);
theMaxStrSize = Size(basegfx::fround<tools::Long>(cellRange.getWidth()), basegfx::fround<tools::Long>(cellRange.getHeight()));
theMaxStrSize.AdjustWidth( -(FRAME_OFFSET) );
theMaxStrSize.AdjustHeight( -(FRAME_OFFSET) );
aScriptedText.SetFonts( &aFont, &aCJKFont, &aCTLFont );
aScriptedText.SetText(cellString, xBreakIter);
aStrSize = aScriptedText.GetTextSize();
if (theMaxStrSize.Height() < aStrSize.Height())
{
// if the string does not fit in the row using this font,
// the default font is used
aScriptedText.SetDefaultFont();
aStrSize = aScriptedText.GetTextSize();
}
while((theMaxStrSize.Width() <= aStrSize.Width()) && (cellString.getLength() > 1))
{
if( eJustification == SvxCellHorJustify::Right )
cellString = cellString.copy(1);
else
cellString = cellString.copy(0, cellString.getLength() - 1 );
aScriptedText.SetText( cellString, xBreakIter );
aStrSize = aScriptedText.GetTextSize();
}
}
else
{
aScriptedText.SetDefaultFont();
aScriptedText.SetText( cellString, xBreakIter );
aStrSize = aScriptedText.GetTextSize();
}
nRightX = sal_uInt16(basegfx::fround(cellRange.getWidth()) - aStrSize.Width() - FRAME_OFFSET);
// vertical (always center):
aPos.AdjustY((mnRowHeight - static_cast<sal_uInt16>(aStrSize.Height())) / 2 );
// horizontal
if (eJustification != SvxCellHorJustify::Standard)
{
sal_uInt16 nHorPos = sal_uInt16((basegfx::fround(cellRange.getWidth())-aStrSize.Width()) / 2);
//sal_uInt16 nHorPos = sal_uInt16((basegfx::fround(cellRange.getWidth())-aStrSize.Width()) / 2);
switch (eJustification)
{
case SvxCellHorJustify::Left:
aPos.AdjustX(FRAME_OFFSET );
break;
case SvxCellHorJustify::Right:
aPos.AdjustX(nRightX );
break;
case SvxCellHorJustify::Block:
case SvxCellHorJustify::Repeat:
case SvxCellHorJustify::Center:
aPos.AdjustX(nHorPos );
break;
// coverity[dead_error_line] - following conditions exist to avoid compiler warning
case SvxCellHorJustify::Standard:
default:
// Standard is not handled here
break;
}
}
else
{
// Standard justification
if (nCol == 0 || nRow == 0)
{
// Text label to the left or sum left adjusted
aPos.AdjustX(FRAME_OFFSET );
}
else
{
// Numbers/Dates right adjusted
aPos.AdjustX(nRightX );
}
}
aScriptedText.DrawText(aPos);
}
#undef FRAME_OFFSET
void ScAutoFmtPreview::DrawBackground(vcl::RenderContext& rRenderContext)
{
if (!pCurData)
return;
for(size_t nRow = 0; nRow < 5; ++nRow)
{
for(size_t nCol = 0; nCol < 5; ++nCol)
{
const SvxBrushItem* pItem =
pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BACKGROUND );
auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::LINECOLOR | vcl::PushFlags::FILLCOLOR);
rRenderContext.SetLineColor();
if (pItem->GetColor() == COL_TRANSPARENT)
rRenderContext.SetFillColor();
else
rRenderContext.SetFillColor( pItem->GetColor() );
const basegfx::B2DRange aCellRange(maArray.GetCellRange( nCol, nRow ));
rRenderContext.DrawRect(
tools::Rectangle(
basegfx::fround<tools::Long>(aCellRange.getMinX()), basegfx::fround<tools::Long>(aCellRange.getMinY()),
basegfx::fround<tools::Long>(aCellRange.getMaxX()), basegfx::fround<tools::Long>(aCellRange.getMaxY())));
}
}
}
void ScAutoFmtPreview::PaintCells(vcl::RenderContext& rRenderContext)
{
if (!pCurData)
return;
// 1) background
if (pCurData->GetIncludeBackground())
DrawBackground(rRenderContext);
// 2) values
for(size_t nRow = 0; nRow < 5; ++nRow)
for(size_t nCol = 0; nCol < 5; ++nCol)
DrawString(rRenderContext, nCol, nRow);
// 3) border
if (!pCurData->GetIncludeFrame())
return;
const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D;
std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(
drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
rRenderContext,
aNewViewInformation2D));
pProcessor2D->process(maArray.CreateB2DPrimitiveArray());
pProcessor2D.reset();
}
void ScAutoFmtPreview::Init()
{
maArray.Initialize( 5, 5 );
mnLabelColWidth = 0;
mnDataColWidth1 = 0;
mnDataColWidth2 = 0;
mnRowHeight = 0;
CalcCellArray( false );
CalcLineMap();
}
void ScAutoFmtPreview::DetectRTL(const ScViewData& rViewData)
{
SCTAB nCurrentTab = rViewData.CurrentTabForData();
ScDocument& rDoc = rViewData.GetDocument();
mbRTL = rDoc.IsLayoutRTL(nCurrentTab);
xBreakIter = rDoc.GetBreakIterator();
}
void ScAutoFmtPreview::CalcCellArray( bool bFitWidthP )
{
maArray.SetXOffset( 2 );
maArray.SetAllColWidths( bFitWidthP ? mnDataColWidth2 : mnDataColWidth1 );
maArray.SetColWidth( 0, mnLabelColWidth );
maArray.SetColWidth( 4, mnLabelColWidth );
maArray.SetYOffset( 2 );
maArray.SetAllRowHeights( mnRowHeight );
aPrvSize.setWidth( maArray.GetWidth() + 4 );
aPrvSize.setHeight( maArray.GetHeight() + 4 );
}
static void lclSetStyleFromBorder( svx::frame::Style& rStyle, const ::editeng::SvxBorderLine* pBorder )
{
rStyle.Set(pBorder, o3tl::convert(1.0, o3tl::Length::twip, o3tl::Length::pt), 5);
}
void ScAutoFmtPreview::CalcLineMap()
{
if ( !pCurData )
return;
for( size_t nRow = 0; nRow < 5; ++nRow )
{
for( size_t nCol = 0; nCol < 5; ++nCol )
{
svx::frame::Style aStyle;
const SvxBoxItem& rItem = GetBoxItem( nCol, nRow );
lclSetStyleFromBorder( aStyle, rItem.GetLeft() );
maArray.SetCellStyleLeft( nCol, nRow, aStyle );
lclSetStyleFromBorder( aStyle, rItem.GetRight() );
maArray.SetCellStyleRight( nCol, nRow, aStyle );
lclSetStyleFromBorder( aStyle, rItem.GetTop() );
maArray.SetCellStyleTop( nCol, nRow, aStyle );
lclSetStyleFromBorder( aStyle, rItem.GetBottom() );
maArray.SetCellStyleBottom( nCol, nRow, aStyle );
lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, true ).GetLine() );
maArray.SetCellStyleTLBR( nCol, nRow, aStyle );
lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, false ).GetLine() );
maArray.SetCellStyleBLTR( nCol, nRow, aStyle );
}
}
}
void ScAutoFmtPreview::NotifyChange( ScAutoFormatData* pNewData )
{
if (pNewData)
{
pCurData = pNewData;
bFitWidth = pNewData->GetIncludeWidthHeight();
}
CalcCellArray( bFitWidth );
CalcLineMap();
Invalidate();
}
void ScAutoFmtPreview::DoPaint(vcl::RenderContext& rRenderContext)
{
auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::ALL);
DrawModeFlags nOldDrawMode = aVD->GetDrawMode();
Size aWndSize(GetOutputSizePixel());
vcl::Font aFont(aVD->GetFont());
const Color& aBackCol = ScModule::get()->GetColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor;
tools::Rectangle aRect(Point(), aWndSize);
aFont.SetTransparent( true );
aVD->SetFont(aFont);
aVD->SetLineColor();
aVD->SetFillColor(aBackCol);
aVD->SetOutputSize(aWndSize);
aVD->DrawRect(aRect);
PaintCells(*aVD);
rRenderContext.SetLineColor();
rRenderContext.SetFillColor(aBackCol);
rRenderContext.DrawRect(aRect);
Point aPos((aWndSize.Width() - aPrvSize.Width()) / 2, (aWndSize.Height() - aPrvSize.Height()) / 2);
if (AllSettings::GetLayoutRTL())
aPos.setX( -aPos.X() );
rRenderContext.DrawOutDev(aPos, aWndSize, Point(), aWndSize, *aVD);
aVD->SetDrawMode(nOldDrawMode);
}
void ScAutoFmtPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/)
{
DoPaint(rRenderContext);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-389
View File
@@ -1,389 +0,0 @@
/* -*- 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 .
*/
#undef SC_DLLIMPLEMENTATION
#include <vcl/svapp.hxx>
#include <vcl/vclenum.hxx>
#include <vcl/weld/weld.hxx>
#include <sfx2/strings.hrc>
#include <sfx2/sfxresid.hxx>
#include <o3tl/string_view.hxx>
#include <vcl/weld/Builder.hxx>
#include <strings.hrc>
#include <global.hxx>
#include <globstr.hrc>
#include <autoform.hxx>
#include <strindlg.hxx>
#include <scuiautofmt.hxx>
#include <scresid.hxx>
#include <helpids.h>
// AutoFormat-Dialog:
ScAutoFormatDlg::ScAutoFormatDlg(weld::Window* pParent,
ScAutoFormat* pAutoFormat,
const ScAutoFormatData* pSelFormatData,
const ScViewData& rViewData)
: GenericDialogController(pParent, u"modules/scalc/ui/autoformattable.ui"_ustr, u"AutoFormatTableDialog"_ustr)
, aStrTitle(ScResId(STR_ADD_AUTOFORMAT_TITLE))
, aStrLabel(ScResId(STR_ADD_AUTOFORMAT_LABEL))
, aStrClose(ScResId(STR_BTN_AUTOFORMAT_CLOSE))
, aStrDelMsg(ScResId(STR_DEL_AUTOFORMAT_MSG))
, aStrRename(ScResId(STR_RENAME_AUTOFORMAT_TITLE))
, pFormat(pAutoFormat)
, pSelFmtData(pSelFormatData)
, m_nIndex(0)
, bCoreDataChanged(false)
, bFmtInserted(false)
, m_xLbFormat(m_xBuilder->weld_tree_view(u"formatlb"_ustr))
, m_xBtnOk(m_xBuilder->weld_button(u"ok"_ustr))
, m_xBtnCancel(m_xBuilder->weld_button(u"cancel"_ustr))
, m_xBtnAdd(m_xBuilder->weld_button(u"add"_ustr))
, m_xBtnRemove(m_xBuilder->weld_button(u"remove"_ustr))
, m_xBtnRename(m_xBuilder->weld_button(u"rename"_ustr))
, m_xBtnNumFormat(m_xBuilder->weld_check_button(u"numformatcb"_ustr))
, m_xBtnBorder(m_xBuilder->weld_check_button(u"bordercb"_ustr))
, m_xBtnFont(m_xBuilder->weld_check_button(u"fontcb"_ustr))
, m_xBtnPattern(m_xBuilder->weld_check_button(u"patterncb"_ustr))
, m_xBtnAlignment(m_xBuilder->weld_check_button(u"alignmentcb"_ustr))
, m_xBtnAdjust(m_xBuilder->weld_check_button(u"autofitcb"_ustr))
, m_xWndPreview(new weld::CustomWeld(*m_xBuilder, u"preview"_ustr, m_aWndPreview))
{
m_aWndPreview.DetectRTL(rViewData);
const int nWidth = m_xLbFormat->get_approximate_digit_width() * 32;
const int nHeight = m_xLbFormat->get_height_rows(8);
m_xLbFormat->set_size_request(nWidth, nHeight);
m_xWndPreview->set_size_request(nWidth, nHeight);
Init();
ScAutoFormat::iterator it = pFormat->begin();
m_aWndPreview.NotifyChange(it->second.get());
}
ScAutoFormatDlg::~ScAutoFormatDlg()
{
}
void ScAutoFormatDlg::Init()
{
m_xLbFormat->connect_selection_changed(LINK(this, ScAutoFormatDlg, SelFmtHdl));
m_xBtnNumFormat->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) );
m_xBtnBorder->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) );
m_xBtnFont->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) );
m_xBtnPattern->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) );
m_xBtnAlignment->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) );
m_xBtnAdjust->connect_toggled( LINK( this, ScAutoFormatDlg, CheckHdl ) );
m_xBtnAdd->connect_clicked ( LINK( this, ScAutoFormatDlg, AddHdl ) );
m_xBtnRemove->connect_clicked ( LINK( this, ScAutoFormatDlg, RemoveHdl ) );
m_xBtnOk->connect_clicked ( LINK( this, ScAutoFormatDlg, CloseHdl ) );
m_xBtnCancel->connect_clicked ( LINK( this, ScAutoFormatDlg, CloseHdl ) );
m_xBtnRename->connect_clicked ( LINK( this, ScAutoFormatDlg, RenameHdl ) );
m_xLbFormat->connect_row_activated( LINK( this, ScAutoFormatDlg, DblClkHdl ) );
for (const auto& rEntry : *pFormat)
m_xLbFormat->append_text(rEntry.second->GetName());
if (pFormat->size() == 1)
m_xBtnRemove->set_sensitive(false);
m_xLbFormat->select(0);
m_xBtnRename->set_sensitive(false);
m_xBtnRemove->set_sensitive(false);
m_nIndex = 0;
UpdateChecks();
if ( !pSelFmtData )
{
m_xBtnAdd->set_sensitive(false);
m_xBtnRemove->set_sensitive(false);
bFmtInserted = true;
}
}
void ScAutoFormatDlg::UpdateChecks()
{
const ScAutoFormatData* pData = pFormat->findByIndex(m_nIndex);
m_xBtnNumFormat->set_active( pData->GetIncludeValueFormat() );
m_xBtnBorder->set_active( pData->GetIncludeFrame() );
m_xBtnFont->set_active( pData->GetIncludeFont() );
m_xBtnPattern->set_active( pData->GetIncludeBackground() );
m_xBtnAlignment->set_active( pData->GetIncludeJustify() );
m_xBtnAdjust->set_active( pData->GetIncludeWidthHeight() );
}
// Handler:
IMPL_LINK(ScAutoFormatDlg, CloseHdl, weld::Button&, rBtn, void)
{
if (&rBtn == m_xBtnOk.get() || &rBtn == m_xBtnCancel.get())
{
if ( bCoreDataChanged )
ScGlobal::GetOrCreateAutoFormat()->Save();
m_xDialog->response( (&rBtn == m_xBtnOk.get()) ? RET_OK : RET_CANCEL );
}
}
IMPL_LINK_NOARG(ScAutoFormatDlg, DblClkHdl, weld::TreeView&, bool)
{
if ( bCoreDataChanged )
ScGlobal::GetOrCreateAutoFormat()->Save();
m_xDialog->response( RET_OK );
return true;
}
IMPL_LINK(ScAutoFormatDlg, CheckHdl, weld::Toggleable&, rBtn, void)
{
ScAutoFormatData* pData = pFormat->findByIndex(m_nIndex);
bool bCheck = rBtn.get_active();
if (&rBtn == m_xBtnNumFormat.get())
pData->SetIncludeValueFormat( bCheck );
else if (&rBtn == m_xBtnBorder.get())
pData->SetIncludeFrame( bCheck );
else if (&rBtn == m_xBtnFont.get())
pData->SetIncludeFont( bCheck );
else if (&rBtn == m_xBtnPattern.get())
pData->SetIncludeBackground( bCheck );
else if (&rBtn == m_xBtnAlignment.get())
pData->SetIncludeJustify( bCheck );
else if (&rBtn == m_xBtnAdjust.get())
pData->SetIncludeWidthHeight( bCheck );
if ( !bCoreDataChanged )
{
m_xBtnCancel->set_label(aStrClose);
bCoreDataChanged = true;
}
m_aWndPreview.NotifyChange( pData );
}
IMPL_LINK_NOARG(ScAutoFormatDlg, AddHdl, weld::Button&, void)
{
if ( bFmtInserted || !pSelFmtData )
return;
OUString aStrStandard( SfxResId(STR_STANDARD) );
OUString aFormatName;
bool bOk = false;
while ( !bOk )
{
ScStringInputDlg aDlg(m_xDialog.get(), aStrTitle, aStrLabel, aFormatName,
HID_SC_ADD_AUTOFMT, HID_SC_AUTOFMT_NAME);
if (aDlg.run() == RET_OK)
{
aFormatName = aDlg.GetInputString();
if ( !aFormatName.isEmpty() && aFormatName != aStrStandard && pFormat->find(aFormatName) == pFormat->end() )
{
std::unique_ptr<ScAutoFormatData> pNewData(
new ScAutoFormatData( *pSelFmtData ));
pNewData->SetName( aFormatName );
ScAutoFormat::iterator it = pFormat->insert(std::move(pNewData));
bFmtInserted = it != pFormat->end();
if ( bFmtInserted )
{
size_t nPos = std::distance(pFormat->begin(), it);
m_xLbFormat->insert_text(nPos, aFormatName);
m_xLbFormat->select_text( aFormatName );
m_xBtnAdd->set_sensitive(false);
if ( !bCoreDataChanged )
{
m_xBtnCancel->set_label( aStrClose );
bCoreDataChanged = true;
}
SelFmtHdl( *m_xLbFormat );
bOk = true;
}
}
if ( !bFmtInserted )
{
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Error, VclButtonsType::OkCancel,
ScResId(STR_INVALID_AFNAME)));
sal_uInt16 nRet = xBox->run();
bOk = ( nRet == RET_CANCEL );
}
}
else
bOk = true;
}
}
IMPL_LINK_NOARG(ScAutoFormatDlg, RemoveHdl, weld::Button&, void)
{
if ( (m_nIndex > 0) && (m_xLbFormat->n_children() > 0) )
{
OUString aMsg = o3tl::getToken(aStrDelMsg, 0, '#' )
+ m_xLbFormat->get_selected_text()
+ o3tl::getToken(aStrDelMsg, 1, '#' );
std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Question, VclButtonsType::YesNo,
aMsg));
xQueryBox->set_default_response(RET_YES);
if (RET_YES == xQueryBox->run())
{
m_xLbFormat->remove(m_nIndex);
m_xLbFormat->select(m_nIndex-1);
if ( m_nIndex-1 == 0 )
m_xBtnRemove->set_sensitive(false);
if ( !bCoreDataChanged )
{
m_xBtnCancel->set_label( aStrClose );
bCoreDataChanged = true;
}
ScAutoFormat::iterator it = pFormat->begin();
std::advance(it, m_nIndex);
pFormat->erase(it);
m_nIndex--;
SelFmtHdl( *m_xLbFormat );
}
}
SelFmtHdl( *m_xLbFormat );
}
IMPL_LINK_NOARG(ScAutoFormatDlg, RenameHdl, weld::Button&, void)
{
bool bOk = false;
while( !bOk )
{
OUString aFormatName = m_xLbFormat->get_selected_text();
OUString aEntry;
ScStringInputDlg aDlg(m_xDialog.get(), aStrRename, aStrLabel, aFormatName,
HID_SC_REN_AFMT_DLG, HID_SC_REN_AFMT_NAME);
if (aDlg.run() == RET_OK)
{
bool bFmtRenamed = false;
aFormatName = aDlg.GetInputString();
if (!aFormatName.isEmpty())
{
ScAutoFormat::iterator it = pFormat->begin(), itEnd = pFormat->end();
for (; it != itEnd; ++it)
{
aEntry = it->second->GetName();
if (aFormatName == aEntry)
break;
}
if (it == itEnd)
{
// no format with this name yet, so we can rename
m_xLbFormat->remove(m_nIndex);
const ScAutoFormatData* p = pFormat->findByIndex(m_nIndex);
std::unique_ptr<ScAutoFormatData> pNewData(new ScAutoFormatData(*p));
it = pFormat->begin();
std::advance(it, m_nIndex);
pFormat->erase(it);
pNewData->SetName( aFormatName );
pFormat->insert(std::move(pNewData));
m_xLbFormat->freeze();
m_xLbFormat->clear();
for (it = pFormat->begin(); it != itEnd; ++it)
{
aEntry = it->second->GetName();
m_xLbFormat->append_text(aEntry);
}
m_xLbFormat->thaw();
m_xLbFormat->select_text(aFormatName);
if ( !bCoreDataChanged )
{
m_xBtnCancel->set_label( aStrClose );
bCoreDataChanged = true;
}
SelFmtHdl( *m_xLbFormat );
bOk = true;
bFmtRenamed = true;
}
}
if( !bFmtRenamed )
{
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Error, VclButtonsType::OkCancel,
ScResId(STR_INVALID_AFNAME)));
bOk = RET_CANCEL == xBox->run();
}
}
else
bOk = true;
}
}
IMPL_LINK_NOARG(ScAutoFormatDlg, SelFmtHdl, weld::TreeView&, void)
{
int nIndex = m_xLbFormat->get_selected_index();
assert(nIndex != -1 && "nothing selected");
m_nIndex = nIndex;
UpdateChecks();
if ( m_nIndex == 0 )
{
m_xBtnRename->set_sensitive(false);
m_xBtnRemove->set_sensitive(false);
}
else
{
m_xBtnRename->set_sensitive(true);
m_xBtnRemove->set_sensitive(true);
}
ScAutoFormatData* p = pFormat->findByIndex(m_nIndex);
m_aWndPreview.NotifyChange(p);
}
OUString ScAutoFormatDlg::GetCurrFormatName()
{
const ScAutoFormatData* p = pFormat->findByIndex(m_nIndex);
return p ? p->GetName() : OUString();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+43 -70
View File
@@ -126,17 +126,15 @@ SC_SIMPLE_SERVICE_INFO( ScAutoFormatFieldObj, u"ScAutoFormatFieldObj"_ustr, u"co
SC_SIMPLE_SERVICE_INFO( ScAutoFormatObj, u"ScAutoFormatObj"_ustr, u"com.sun.star.sheet.TableAutoFormat"_ustr )
SC_SIMPLE_SERVICE_INFO( ScAutoFormatsObj, u"stardiv.StarCalc.ScAutoFormatsObj"_ustr, SCAUTOFORMATSOBJ_SERVICE )
static bool lcl_FindAutoFormatIndex( const ScAutoFormat& rFormats, std::u16string_view rName, sal_uInt16& rOutIndex )
static bool lcl_FindAutoFormatIndex(const ScAutoFormat& rFormats, std::u16string_view rName,
sal_uInt16& rOutIndex)
{
ScAutoFormat::const_iterator itBeg = rFormats.begin(), itEnd = rFormats.end();
for (ScAutoFormat::const_iterator it = itBeg; it != itEnd; ++it)
for (size_t i = 0; i < rFormats.size(); i++)
{
const ScAutoFormatData *const pEntry = it->second.get();
const OUString& aEntryName = pEntry->GetName();
if ( aEntryName == rName )
const ScAutoFormatData* pData = rFormats.GetData(i);
if (pData->GetName() == rName)
{
size_t nPos = std::distance(itBeg, it);
rOutIndex = nPos;
rOutIndex = i;
return true;
}
}
@@ -201,10 +199,10 @@ void SAL_CALL ScAutoFormatsObj::insertByName( const OUString& aName, const uno::
throw container::ElementExistException();
}
std::unique_ptr<ScAutoFormatData> pNew(new ScAutoFormatData());
ScAutoFormatData* pNew = new ScAutoFormatData();
pNew->SetName( aName );
if (pFormats->insert(std::move(pNew)) != pFormats->end())
if (pFormats->InsertAutoFormat(pNew))
{
//! notify to other objects
pFormats->Save();
@@ -215,6 +213,8 @@ void SAL_CALL ScAutoFormatsObj::insertByName( const OUString& aName, const uno::
pFormatObj->InitFormat( nNewIndex ); // can be used now
bDone = true;
}
ScGlobal::ResetAutoFormat();
}
else
{
@@ -243,17 +243,16 @@ void SAL_CALL ScAutoFormatsObj::removeByName( const OUString& aName )
{
SolarMutexGuard aGuard;
ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat();
ScAutoFormat::iterator it = pFormats->find(aName);
if (it == pFormats->end())
ScAutoFormatData* pData = pFormats->FindAutoFormat(aName);
if (!pData)
{
throw container::NoSuchElementException();
}
pFormats->erase(it);
pFormats->ReleaseAutoFormat(aName);
//! notify to other objects
pFormats->Save(); // save immediately
ScGlobal::ResetAutoFormat();
}
// container::XEnumerationAccess
@@ -309,11 +308,11 @@ uno::Sequence<OUString> SAL_CALL ScAutoFormatsObj::getElementNames()
ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat();
uno::Sequence<OUString> aSeq(pFormats->size());
OUString* pAry = aSeq.getArray();
size_t i = 0;
for (const auto& rEntry : *pFormats)
for (size_t i = 0; i < pFormats->size(); i++)
{
pAry[i] = rEntry.second->GetName();
++i;
ScAutoFormatData* pData = pFormats->GetData(i);
if (pData)
pAry[i] = pData->GetName();
}
return aSeq;
}
@@ -321,9 +320,8 @@ uno::Sequence<OUString> SAL_CALL ScAutoFormatsObj::getElementNames()
sal_Bool SAL_CALL ScAutoFormatsObj::hasByName( const OUString& aName )
{
SolarMutexGuard aGuard;
sal_uInt16 nDummy;
return lcl_FindAutoFormatIndex(
*ScGlobal::GetOrCreateAutoFormat(), aName, nDummy );
auto pData = ScGlobal::GetOrCreateAutoFormat()->FindAutoFormat(aName);
return pData ? true : false;
}
ScAutoFormatObj::ScAutoFormatObj(sal_uInt16 nIndex) :
@@ -334,17 +332,6 @@ ScAutoFormatObj::ScAutoFormatObj(sal_uInt16 nIndex) :
ScAutoFormatObj::~ScAutoFormatObj()
{
// If an AutoFormat object is released, then eventually changes are saved
// so that they become visible in e.g Writer
if (IsInserted())
{
ScAutoFormat* pFormats = ScGlobal::GetAutoFormat();
if ( pFormats && pFormats->IsSaveLater() )
pFormats->Save();
// Save() resets flag SaveLater
}
}
void ScAutoFormatObj::InitFormat( sal_uInt16 nNewIndex )
@@ -412,7 +399,7 @@ OUString SAL_CALL ScAutoFormatObj::getName()
SolarMutexGuard aGuard;
ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat();
if (IsInserted() && nFormatIndex < pFormats->size())
return pFormats->findByIndex(nFormatIndex)->GetName();
return pFormats->GetData(nFormatIndex)->GetName();
return OUString();
}
@@ -430,23 +417,9 @@ void SAL_CALL ScAutoFormatObj::setName( const OUString& aNewName )
throw uno::RuntimeException();
}
ScAutoFormat::iterator it = pFormats->begin();
std::advance(it, nFormatIndex);
ScAutoFormatData *const pData = it->second.get();
assert(pData && "AutoFormat data not available");
std::unique_ptr<ScAutoFormatData> pNew(new ScAutoFormatData(*pData));
pNew->SetName( aNewName );
pFormats->erase(it);
it = pFormats->insert(std::move(pNew));
if (it != pFormats->end())
if (ScAutoFormatData* pData = pFormats->GetData(nFormatIndex))
{
ScAutoFormat::iterator itBeg = pFormats->begin();
nFormatIndex = std::distance(itBeg, it);
//! notify to other objects
pFormats->SetSaveLater(true);
pData->SetName(aNewName);
}
else
{
@@ -472,27 +445,27 @@ void SAL_CALL ScAutoFormatObj::setPropertyValue(
if (!(IsInserted() && nFormatIndex < pFormats->size()))
return;
ScAutoFormatData* pData = pFormats->findByIndex(nFormatIndex);
ScAutoFormatData* pData = pFormats->GetData(nFormatIndex);
OSL_ENSURE(pData,"AutoFormat data not available");
bool bBool = false;
if (aPropertyName == SC_UNONAME_INCBACK && (aValue >>= bBool))
pData->SetIncludeBackground( bBool );
pData->SetBackground( bBool );
else if (aPropertyName == SC_UNONAME_INCBORD && (aValue >>= bBool))
pData->SetIncludeFrame( bBool );
pData->SetFrame( bBool );
else if (aPropertyName == SC_UNONAME_INCFONT && (aValue >>= bBool))
pData->SetIncludeFont( bBool );
pData->SetFont( bBool );
else if (aPropertyName == SC_UNONAME_INCJUST && (aValue >>= bBool))
pData->SetIncludeJustify( bBool );
pData->SetJustify( bBool );
else if (aPropertyName == SC_UNONAME_INCNUM && (aValue >>= bBool))
pData->SetIncludeValueFormat( bBool );
pData->SetValueFormat( bBool );
else if (aPropertyName == SC_UNONAME_INCWIDTH && (aValue >>= bBool))
pData->SetIncludeWidthHeight( bBool );
pData->SetWidthHeight( bBool );
// else error
//! notify to other objects
pFormats->SetSaveLater(true);
pFormats->Save();
}
uno::Any SAL_CALL ScAutoFormatObj::getPropertyValue( const OUString& aPropertyName )
@@ -503,24 +476,24 @@ uno::Any SAL_CALL ScAutoFormatObj::getPropertyValue( const OUString& aPropertyNa
ScAutoFormat* pFormats = ScGlobal::GetOrCreateAutoFormat();
if (IsInserted() && nFormatIndex < pFormats->size())
{
ScAutoFormatData* pData = pFormats->findByIndex(nFormatIndex);
ScAutoFormatData* pData = pFormats->GetData(nFormatIndex);
assert(pData && "AutoFormat data not available");
bool bValue;
bool bError = false;
if (aPropertyName == SC_UNONAME_INCBACK)
bValue = pData->GetIncludeBackground();
bValue = pData->IsBackground();
else if (aPropertyName == SC_UNONAME_INCBORD)
bValue = pData->GetIncludeFrame();
bValue = pData->IsFrame();
else if (aPropertyName == SC_UNONAME_INCFONT)
bValue = pData->GetIncludeFont();
bValue = pData->IsFont();
else if (aPropertyName == SC_UNONAME_INCJUST)
bValue = pData->GetIncludeJustify();
bValue = pData->IsJustify();
else if (aPropertyName == SC_UNONAME_INCNUM)
bValue = pData->GetIncludeValueFormat();
bValue = pData->IsValueFormat();
else if (aPropertyName == SC_UNONAME_INCWIDTH)
bValue = pData->GetIncludeWidthHeight();
bValue = pData->IsWidthHeight();
else
bError = true; // unknown property
@@ -564,7 +537,7 @@ void SAL_CALL ScAutoFormatFieldObj::setPropertyValue(
if ( !(pEntry && pEntry->nWID && nFormatIndex < pFormats->size()) )
return;
ScAutoFormatData* pData = pFormats->findByIndex(nFormatIndex);
ScAutoFormatData* pData = pFormats->GetData(nFormatIndex);
if ( IsScItemWid( pEntry->nWID ) )
{
@@ -613,7 +586,7 @@ void SAL_CALL ScAutoFormatFieldObj::setPropertyValue(
if (bDone)
//! Notify to other objects?
pFormats->SetSaveLater(true);
pFormats->Save();
}
}
else
@@ -631,7 +604,7 @@ void SAL_CALL ScAutoFormatFieldObj::setPropertyValue(
pData->PutItem( nFieldIndex, aOuter );
//! Notify for other objects?
pFormats->SetSaveLater(true);
pFormats->Save();
}
}
break;
@@ -646,7 +619,7 @@ void SAL_CALL ScAutoFormatFieldObj::setPropertyValue(
pData->PutItem( nFieldIndex, aOuter );
//! Notify for other objects?
pFormats->SetSaveLater(true);
pFormats->Save();
}
}
break;
@@ -665,7 +638,7 @@ uno::Any SAL_CALL ScAutoFormatFieldObj::getPropertyValue( const OUString& aPrope
if ( pEntry && pEntry->nWID && nFormatIndex < pFormats->size() )
{
const ScAutoFormatData* pData = pFormats->findByIndex(nFormatIndex);
const ScAutoFormatData* pData = pFormats->GetData(nFormatIndex);
if ( IsScItemWid( pEntry->nWID ) )
{
+11 -4
View File
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/types.h>
#include <scitems.hxx>
#include <editeng/eeitem.hxx>
#include <o3tl/safeint.hxx>
@@ -5183,12 +5184,18 @@ void SAL_CALL ScCellRangeObj::autoFormat( const OUString& aName )
if ( pDocSh )
{
ScAutoFormat* pAutoFormat = ScGlobal::GetOrCreateAutoFormat();
ScAutoFormat::const_iterator it = pAutoFormat->find(aName);
if (it == pAutoFormat->end())
sal_Int16 nIndex = -1;
for (size_t i = 0; i < pAutoFormat->size(); i++)
{
if (ScAutoFormatData* pData = pAutoFormat->GetData(i))
{
if (pData->GetName() == aName)
nIndex = i;
}
}
if (nIndex == -1)
throw lang::IllegalArgumentException();
ScAutoFormat::const_iterator itBeg = pAutoFormat->begin();
size_t nIndex = std::distance(itBeg, it);
pDocSh->GetDocFunc().AutoFormat(aRange, nullptr, nIndex, true);
}
+19 -11
View File
@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <global.hxx>
#include <svx/dialog/TableAutoFmtDlg.hxx>
#include <scitems.hxx>
#include <editeng/editview.hxx>
#include <editeng/editeng.hxx>
@@ -1027,9 +1029,15 @@ void ScCellShell::Execute( SfxRequest& rReq )
{
const SfxStringItem& rNameItem = pReqArgs->Get( SID_AUTOFORMAT );
ScAutoFormat* pFormat = ScGlobal::GetOrCreateAutoFormat();
ScAutoFormat::const_iterator it = pFormat->find(rNameItem.GetValue());
ScAutoFormat::const_iterator itBeg = pFormat->begin();
size_t nIndex = std::distance(itBeg, it);
size_t nIndex = 0;
for (size_t i = 0; i < pFormat->size(); i++)
{
if (ScAutoFormatData* pData = pFormat->GetData(i))
{
if (pData->GetName() == rNameItem.GetValue())
nIndex = i;
}
}
pTabViewShell->AutoFormat( nIndex );
@@ -1038,13 +1046,12 @@ void ScCellShell::Execute( SfxRequest& rReq )
}
else
{
ScGlobal::ClearAutoFormat();
std::unique_ptr<ScAutoFormatData> pNewEntry(pTabViewShell->CreateAutoFormatData());
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
SCTAB nCurrentTab = GetViewData().GetTabNumber();
bool bRTL = GetViewData().GetDocument().IsLayoutRTL(nCurrentTab);
ScopedVclPtr<AbstractScAutoFormatDlg> pDlg(pFact->CreateScAutoFormatDlg(pDlgParent, ScGlobal::GetOrCreateAutoFormat(), pNewEntry.get(), GetViewData()));
if ( pDlg->Execute() == RET_OK )
SvxTableAutoFmtDlg aDlg(*ScGlobal::GetOrCreateAutoFormat(), "", pDlgParent,
false, bRTL);
if (aDlg.run() == RET_OK)
{
ScEditableTester aTester = ScEditableTester::CreateAndTestView(pTabViewShell);
if ( !aTester.IsEditable() )
@@ -1053,9 +1060,10 @@ void ScCellShell::Execute( SfxRequest& rReq )
}
else
{
pTabViewShell->AutoFormat( pDlg->GetIndex() );
pTabViewShell->AutoFormat(aDlg.GetIndex());
rReq.AppendItem( SfxStringItem( SID_AUTOFORMAT, pDlg->GetCurrFormatName() ) );
rReq.AppendItem(
SfxStringItem(SID_AUTOFORMAT, aDlg.GetCurrFormatName()));
rReq.Done();
}
}
-3
View File
@@ -8580,7 +8580,6 @@ sc/source/ui/inc/anyrefdg.hxx
sc/source/ui/inc/areasave.hxx
sc/source/ui/inc/areasdlg.hxx
sc/source/ui/inc/asciiopt.hxx
sc/source/ui/inc/autofmt.hxx
sc/source/ui/inc/autostyl.hxx
sc/source/ui/inc/cbutton.hxx
sc/source/ui/inc/cellmergeoption.hxx
@@ -8685,7 +8684,6 @@ sc/source/ui/inc/rfindlst.hxx
sc/source/ui/inc/scendlg.hxx
sc/source/ui/inc/scui_def.hxx
sc/source/ui/inc/scuiasciiopt.hxx
sc/source/ui/inc/scuiautofmt.hxx
sc/source/ui/inc/scuiimoptdlg.hxx
sc/source/ui/inc/scuitphfedit.hxx
sc/source/ui/inc/searchresults.hxx
@@ -8762,7 +8760,6 @@ sc/source/ui/miscdlgs/mtrindlg.cxx
sc/source/ui/miscdlgs/optsolver.cxx
sc/source/ui/miscdlgs/protectiondlg.cxx
sc/source/ui/miscdlgs/redcom.cxx
sc/source/ui/miscdlgs/scuiautofmt.cxx
sc/source/ui/miscdlgs/sharedocdlg.cxx
sc/source/ui/miscdlgs/simpref.cxx
sc/source/ui/miscdlgs/solveroptions.cxx