https://bugs.documentfoundation.org/show_bug.cgi?id=62717

--- Comment #31 from Alexis PAQUIN <[email protected]> ---
After debug and analysis, the function originally rename masks in a template
document is in the file ./libo-core/sd/source/ui/docshell/docshel4.cxx

The method is :
bool DrawDocShell::SaveAsOwnFormat( SfxMedium& rMedium )

This method has a side effect, she’s overwrite the mask name performed by the
user.

The most surprising in this method, that we are rename all masks name when the
file name is valued. More, the file name « aLayoutName » is valued every time
in the first part of this method : 


if( rMedium.GetItemSet()->GetItemState(SID_TEMPLATE_NAME, false,
reinterpret_cast<const SfxPoolItem**>(& pLayoutItem) ) == SfxItemState::SET )
        {
            aLayoutName = pLayoutItem->GetValue();
        }
        else
        {
            INetURLObject aURL( rMedium.GetName() );
            aURL.removeExtension();
            aLayoutName = aURL.getName();
        }


The fact that the file name is everytime valued make useless the code in the
second part of this method :

if (!aLayoutName.isEmpty())
        {
            sal_uInt32 nCount = mpDoc->GetMasterSdPageCount(PK_STANDARD);
            for (sal_uInt32 i = 0; i < nCount; ++i)
            {
                 OUString aOldPageLayoutName = mpDoc->GetMasterSdPage(i,
PK_STANDARD)->GetLayoutName();
                 OUString aNewLayoutName = aLayoutName;
                 // Don't add suffix for the first master page
                 if( i > 0 )
                    aNewLayoutName += OUString::number(i);

              mpDoc->RenameLayoutTemplate(aOldPageLayoutName, aNewLayoutName);
            }
        }

Do you think that the code in if (!aLayoutName.isEmpty()) is still useful ?
It should not be the reverse, do an action only when the file name isn’t valued
?

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to