Until now the 'local' StyleSheet got set, but that may not be the same as the original. It was/gets identified just by searching by name and type, not comparing content. What to do? We could... (a) the Style-Friendly way: - check if StyleSheet is identical - if not, create a new in-between StyleSheet hosting missing Items - if yes, use, done. (b) the pragmatic/practical way: - Just hard-attribute the Items that are detected as different similar to what BurnInStyleSheetAttributes does/did, but only for a view differing Items (b) is the most simple for now, but will lead to more hard attributes. The other possibilities will be better in the long term. For now, I will use (b). Note that there are more cases in that VERY complex and grown stuff emerging from SdDrawDocument::PasteBookmarkAsPage. More things will need to be fixed, see this as a 1st step. Needed to adapt postProcessAfterCloneToDifferentModel due to UT testTdf96206 failing, see comment there for details. That 1st implementation showed weaknesses with those Items critical and only on MasterPages, so decided to give up on that and implement ContentCompare to SdPage::Equals. That was easier than thought: No parameter needed, only used by InsertBookmarkAsPage_FindDuplicateLayouts::operator(). Thus, SdPage::Equals needs no change, just SdrObject::Equals. Due to still problems with Items corrected in Objects on MasterPages I will for now exclude this. Could now isolate remaining problems, these are defaults and/or PresObj things on MasterPages. Important is that I can completely correct all Items for all Objects in postProcessAfterCloneToDifferentModel. I can react to these false-positives in the ContentCompare in SdrObject::Equals. Signed-off-by: Armin Le Grand (collabora) <Armin.LeGrand@collabora.com> Change-Id: I10e17c8d6a893dbe92ab716182f07bafce1f3284 Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/6595 Tested-by: Jenkins CPCI <releng@collaboraoffice.com> Reviewed-by: Armin Le Grand <armin.legrand@collabora.com> (cherry picked from commit 92ffaeac04c5c8586006b026f29ce12fba3674f1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211729 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
245 lines
7.3 KiB
C++
245 lines
7.3 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column:100 -*- */
|
|
/*
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#include <config_features.h>
|
|
#include <rtl/ustring.hxx>
|
|
#include <rtl/ustrbuf.hxx>
|
|
|
|
#include <comphelper/lok.hxx>
|
|
|
|
#include <sal/log.hxx>
|
|
#include <svx/svdmodel.hxx>
|
|
#include <svx/annotation/AnnotationObject.hxx>
|
|
#include <svx/annotation/ObjectAnnotationData.hxx>
|
|
#include <sdr/properties/rectangleproperties.hxx>
|
|
#include <svx/xfillit0.hxx>
|
|
#include <svx/xflclit.hxx>
|
|
#include <svx/xlineit0.hxx>
|
|
#include <svx/xlnclit.hxx>
|
|
#include <svx/xlnwtit.hxx>
|
|
#include <svx/sdtfsitm.hxx>
|
|
#include <svx/sdooitm.hxx>
|
|
#include <svx/sdtagitm.hxx>
|
|
#include <svx/sdasitm.hxx>
|
|
#include <svx/sdtditm.hxx>
|
|
#include <svtools/colorcfg.hxx>
|
|
|
|
#include <vcl/settings.hxx>
|
|
#include <vcl/svapp.hxx>
|
|
#include <editeng/fhgtitem.hxx>
|
|
#include <editeng/colritem.hxx>
|
|
#include <o3tl/unit_conversion.hxx>
|
|
|
|
using namespace css;
|
|
|
|
namespace sdr::annotation
|
|
{
|
|
namespace
|
|
{
|
|
OUString createInitials(OUString const& rName)
|
|
{
|
|
OUStringBuffer sInitials;
|
|
|
|
const sal_Unicode* pStr = rName.getStr();
|
|
sal_Int32 nLength = rName.getLength();
|
|
|
|
while (nLength)
|
|
{
|
|
// skip whitespace
|
|
while (nLength && (*pStr <= ' '))
|
|
{
|
|
nLength--;
|
|
pStr++;
|
|
}
|
|
|
|
// take letter
|
|
if (nLength)
|
|
{
|
|
sInitials.append(*pStr);
|
|
nLength--;
|
|
pStr++;
|
|
}
|
|
|
|
// skip letters until whitespace
|
|
while (nLength && (*pStr > ' '))
|
|
{
|
|
nLength--;
|
|
pStr++;
|
|
}
|
|
}
|
|
|
|
return sInitials.makeStringAndClear();
|
|
}
|
|
|
|
Color getColorLight(sal_uInt16 aAuthorIndex)
|
|
{
|
|
if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode())
|
|
{
|
|
svtools::ColorConfig aColorConfig;
|
|
switch (aAuthorIndex % 9)
|
|
{
|
|
case 0:
|
|
return aColorConfig.GetColorValue(svtools::AUTHOR1).nColor;
|
|
case 1:
|
|
return aColorConfig.GetColorValue(svtools::AUTHOR2).nColor;
|
|
case 2:
|
|
return aColorConfig.GetColorValue(svtools::AUTHOR3).nColor;
|
|
case 3:
|
|
return aColorConfig.GetColorValue(svtools::AUTHOR4).nColor;
|
|
case 4:
|
|
return aColorConfig.GetColorValue(svtools::AUTHOR5).nColor;
|
|
case 5:
|
|
return aColorConfig.GetColorValue(svtools::AUTHOR6).nColor;
|
|
case 6:
|
|
return aColorConfig.GetColorValue(svtools::AUTHOR7).nColor;
|
|
case 7:
|
|
return aColorConfig.GetColorValue(svtools::AUTHOR8).nColor;
|
|
case 8:
|
|
return aColorConfig.GetColorValue(svtools::AUTHOR9).nColor;
|
|
}
|
|
}
|
|
|
|
return COL_WHITE;
|
|
}
|
|
}
|
|
|
|
AnnotationObject::AnnotationObject(SdrModel& rSdrModel, AnnotationObject const& rSource)
|
|
: SdrRectObj(rSdrModel, rSource)
|
|
{
|
|
setup();
|
|
}
|
|
|
|
AnnotationObject::AnnotationObject(SdrModel& rSdrModel, tools::Rectangle const& rRectangle,
|
|
sdr::annotation::AnnotationViewData const& rAnnotationViewData)
|
|
: SdrRectObj(rSdrModel, rRectangle)
|
|
, maViewData(rAnnotationViewData)
|
|
{
|
|
osl_atomic_increment(&m_refCount);
|
|
|
|
const bool bUndo(rSdrModel.IsUndoEnabled());
|
|
rSdrModel.EnableUndo(false);
|
|
MakeNameUnique();
|
|
rSdrModel.EnableUndo(bUndo);
|
|
|
|
osl_atomic_decrement(&m_refCount);
|
|
setup();
|
|
}
|
|
|
|
void AnnotationObject::setup()
|
|
{
|
|
setAsAnnotationObject();
|
|
mbTextFrame = true; // need this so the frame can be adjusted to the text
|
|
bool bLOK = comphelper::LibreOfficeKit::isActive();
|
|
SetVisible(getSdrModelFromSdrObject().IsPDFDocument() || !bLOK);
|
|
}
|
|
|
|
void AnnotationObject::ApplyAnnotationName()
|
|
{
|
|
if (mpAnnotationData->mxAnnotation)
|
|
{
|
|
OUString sInitials(mpAnnotationData->mxAnnotation->getInitials());
|
|
if (sInitials.isEmpty())
|
|
sInitials = createInitials(mpAnnotationData->mxAnnotation->getAuthor());
|
|
SetText(sInitials + u" "_ustr + OUString::number(maViewData.nIndex));
|
|
}
|
|
else
|
|
{
|
|
SetText(u"🗅"_ustr);
|
|
}
|
|
|
|
Color aColor(getColorLight(maViewData.nAuthorIndex));
|
|
|
|
SfxItemSet aItemSet = GetMergedItemSet();
|
|
aItemSet.Put(XFillStyleItem(drawing::FillStyle_SOLID));
|
|
aItemSet.Put(XFillColorItem(OUString(), aColor));
|
|
|
|
Color aBorderColor(aColor);
|
|
if (aColor.IsDark())
|
|
aBorderColor.IncreaseLuminance(32);
|
|
else
|
|
aBorderColor.DecreaseLuminance(32);
|
|
|
|
aItemSet.Put(XLineStyleItem(drawing::LineStyle_SOLID));
|
|
aItemSet.Put(XLineColorItem(OUString(), aBorderColor));
|
|
aItemSet.Put(XLineWidthItem(o3tl::convert(0, o3tl::Length::pt, o3tl::Length::mm100)));
|
|
|
|
aItemSet.Put(SvxFontHeightItem(o3tl::convert(10, o3tl::Length::pt, o3tl::Length::mm100), 100,
|
|
EE_CHAR_FONTHEIGHT));
|
|
|
|
aItemSet.Put(SvxColorItem(aColor.IsDark() ? COL_WHITE : COL_BLACK, EE_CHAR_COLOR));
|
|
|
|
aItemSet.Put(SdrTextFitToSizeTypeItem(drawing::TextFitToSizeType_NONE));
|
|
|
|
aItemSet.Put(makeSdrTextWordWrapItem(false));
|
|
aItemSet.Put(makeSdrTextAutoGrowWidthItem(true));
|
|
aItemSet.Put(makeSdrTextAutoGrowHeightItem(true));
|
|
aItemSet.Put(makeSdrTextLeftDistItem(50));
|
|
aItemSet.Put(makeSdrTextRightDistItem(50));
|
|
aItemSet.Put(makeSdrTextUpperDistItem(50));
|
|
aItemSet.Put(makeSdrTextLowerDistItem(50));
|
|
|
|
SetMergedItemSet(aItemSet);
|
|
|
|
// Update the annotation size after the auto-sizing the frame to content does its magic
|
|
auto& xAnnotationData = getAnnotationData();
|
|
css::geometry::RealSize2D aRealSize2D{ GetLogicRect().GetWidth() / 100.0,
|
|
GetLogicRect().GetHeight() / 100.0 };
|
|
xAnnotationData->mxAnnotation->SetSize(aRealSize2D);
|
|
}
|
|
|
|
AnnotationObject::~AnnotationObject() {}
|
|
|
|
void AnnotationObject::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
|
|
{
|
|
rInfo.bMoveAllowed = true;
|
|
rInfo.bResizeFreeAllowed = false;
|
|
rInfo.bResizePropAllowed = false;
|
|
rInfo.bRotateFreeAllowed = false;
|
|
rInfo.bRotate90Allowed = false;
|
|
rInfo.bMirrorFreeAllowed = false;
|
|
rInfo.bMirror45Allowed = false;
|
|
rInfo.bMirror90Allowed = false;
|
|
rInfo.bTransparenceAllowed = false;
|
|
rInfo.bShearAllowed = false;
|
|
rInfo.bEdgeRadiusAllowed = false;
|
|
rInfo.bNoOrthoDesired = false;
|
|
rInfo.bNoContortion = false;
|
|
rInfo.bCanConvToPath = false;
|
|
rInfo.bCanConvToPoly = false;
|
|
rInfo.bCanConvToContour = false;
|
|
rInfo.bCanConvToPathLineToArea = false;
|
|
rInfo.bCanConvToPolyLineToArea = false;
|
|
}
|
|
|
|
SdrObjKind AnnotationObject::GetObjIdentifier() const { return SdrObjKind::Annotation; }
|
|
|
|
OUString AnnotationObject::TakeObjNameSingul() const
|
|
{
|
|
OUString sOutName(u"Annotation"_ustr);
|
|
OUString aName(GetName());
|
|
|
|
if (!aName.isEmpty())
|
|
sOutName += u" '"_ustr + aName + u"'"_ustr;
|
|
|
|
return sOutName;
|
|
}
|
|
|
|
OUString AnnotationObject::TakeObjNamePlural() const { return u"Annotations"_ustr; }
|
|
|
|
rtl::Reference<SdrObject> AnnotationObject::implCloneSdrObject(SdrModel& rTargetModel) const
|
|
{
|
|
return new AnnotationObject(rTargetModel, *this);
|
|
}
|
|
|
|
bool AnnotationObject::HasTextEdit() const { return false; }
|
|
|
|
} // end sdr::annotation
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|