[TD]handle ScaleType in old documents

This commit is contained in:
Wanderer Fan
2022-03-09 13:14:41 -05:00
committed by WandererFan
parent dd1b0e0a3d
commit bbffb3f413
3 changed files with 27 additions and 0 deletions

View File

@@ -170,6 +170,7 @@ void DrawProjGroupItem::autoPosition()
void DrawProjGroupItem::onDocumentRestored()
{
// Base::Console().Message("DPGI::onDocumentRestored() - %s\n", getNameInDocument());
DrawView::onDocumentRestored();
App::DocumentObjectExecReturn* rc = DrawProjGroupItem::execute();
if (rc) {
delete rc;

View File

@@ -239,8 +239,33 @@ void DrawView::onDocumentRestored()
{
handleXYLock();
setScaleAttribute();
validateScale();
DrawView::execute();
}
//in versions before 0.20 Scale and ScaleType were mishandled.
//In order to not introduce unintended drawing changes in later
//versions, ScaleType Page must be modified if view Scale does
//not match Page Scale
void DrawView::validateScale()
{
if (ScaleType.isValue("Custom")) {
//nothing to do here
return;
}
DrawPage* page = findParentPage();
if (page) {
if (ScaleType.isValue("Page")) {
double pageScale = page->Scale.getValue();
double myScale = Scale.getValue();
if (!DrawUtil::fpCompare(pageScale, myScale)) {
ScaleType.setValue("Custom");
ScaleType.purgeTouched();
}
}
}
}
/**
* @brief DrawView::countParentPages
* Fixes a crash in TechDraw when user creates duplicate page without dependencies

View File

@@ -109,6 +109,7 @@ public:
protected:
virtual void onChanged(const App::Property* prop) override;
virtual void validateScale();
std::string pageFeatName;
bool autoPos;
bool mouseMove;