summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2023-03-22 22:10:21 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2023-03-30 22:43:09 +0000
commitcb3b8b0aaa9d53bd4b4a74d22b87d46e77835206 (patch)
tree97cc0b9482d1027e58685718741691bd2fc14e30 /sc
parent4ceb287c6d42940adf887f36c4f88abae44e0022 (diff)
sc drawstyles: Add a default style and make use of it
The style is empty, similar to the default cell style, thus fall backs to the pool defaults for everything. This ensures compatibility with existing documents, despite the fact that the default style is applied to all shapes upon import. In addition, people who will ignore styles and just continue to use DF, will have their spreadsheets look the same in older versions that don't support styles. For this reason I also opted to not set a dedicated style for images and OLE objects via SdrModel::SetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj, unlike Impress/Draw, and continue setting the "no fill and no line" override as DF. Change-Id: I11554044a1aaf386dc6c4acdbab798fc5a231adc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149359 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/drwlayer.hxx1
-rw-r--r--sc/source/core/data/documen9.cxx1
-rw-r--r--sc/source/core/data/drwlayer.cxx7
-rw-r--r--sc/source/core/data/postit.cxx5
-rw-r--r--sc/source/core/tool/stylehelper.cxx10
5 files changed, 24 insertions, 0 deletions
diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx
index 55c1031d099a..c127f597bab2 100644
--- a/sc/inc/drwlayer.hxx
+++ b/sc/inc/drwlayer.hxx
@@ -118,6 +118,7 @@ public:
virtual SdrModel* AllocModel() const override;
virtual void SetChanged( bool bFlg = true ) override;
+ void CreateDefaultStyles();
bool HasObjects() const;
bool ScAddPage( SCTAB nTab );
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index e6a6501c46e4..34c25c761db4 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -130,6 +130,7 @@ void ScDocument::InitDrawLayer( SfxObjectShell* pDocShell )
OSL_ENSURE(!pLocalPool->GetSecondaryPool(), "OOps, already a secondary pool set where the DrawingLayer ItemPool is to be placed (!)");
pLocalPool->SetSecondaryPool(&mpDrawLayer->GetItemPool());
}
+ mpDrawLayer->CreateDefaultStyles();
}
// Drawing pages are accessed by table number, so they must also be present
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 359bf3b1e7be..263c5698c15a 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -343,6 +343,13 @@ ScDrawLayer::~ScDrawLayer()
}
}
+void ScDrawLayer::CreateDefaultStyles()
+{
+ // Default
+ auto pSheet = &GetStyleSheetPool()->Make(ScResId(STR_STYLENAME_STANDARD), SfxStyleFamily::Frame, SfxStyleSearchBits::ScStandard);
+ SetDefaultStyleSheet(static_cast<SfxStyleSheet*>(pSheet));
+}
+
void ScDrawLayer::UseHyphenator()
{
if (!bHyphenatorSet)
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index f33ed9dd6b68..00aab1d52030 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -759,6 +759,11 @@ void ScPostIt::CreateCaption( const ScAddress& rPos, const SdrCaptionObj* pCapti
}
else
{
+ // set default size, undoing sdr::TextProperties::SetStyleSheet's
+ // adjustment that use a wrong min height.
+ maNoteData.mxCaption->SetMergedItem(makeSdrTextMinFrameHeightItem(SC_NOTECAPTION_HEIGHT));
+ maNoteData.mxCaption->SetMergedItem(makeSdrTextMinFrameWidthItem(SC_NOTECAPTION_WIDTH));
+ maNoteData.mxCaption->NbcAdjustTextFrameWidthAndHeight();
// set default formatting and default position
ScCaptionUtil::SetDefaultItems( *maNoteData.mxCaption, mrDoc, nullptr );
aCreator.AutoPlaceCaption();
diff --git a/sc/source/core/tool/stylehelper.cxx b/sc/source/core/tool/stylehelper.cxx
index e9a920500e79..3adcfb4847bc 100644
--- a/sc/source/core/tool/stylehelper.cxx
+++ b/sc/source/core/tool/stylehelper.cxx
@@ -97,6 +97,16 @@ static const ScDisplayNameMap* lcl_GetStyleNameMap( SfxStyleFamily nType )
};
return aPageMap;
}
+ else if ( nType == SfxStyleFamily::Frame )
+ {
+ static ScDisplayNameMap const aGraphicMap[]
+ {
+ { ScResId( STR_STYLENAME_STANDARD ), OUString(SC_STYLE_PROG_STANDARD) },
+ // last entry remains empty
+ { OUString(), OUString() },
+ };
+ return aGraphicMap;
+ }
OSL_FAIL("invalid family");
return nullptr;
}