tdf#148810 pptx import: Depth set by EE_PARA_OUTLLEVEL
It isn't enough to do Paragraph->SetDepth(). It must match the property EE_PARA_OUTLLEVEL. So I was hoping that the only thing I needed was the "set property" helper. But unit tests showed that I also needed "get property" to return an empty aAny instead of a -1. My confidence level on this one is fairly low. This code is way too tangled and weird. I'm sure the concept is right (that the property is the most important thing) but all of the wonkiness around the level means any changes to the implementation will be fragile. make UITest_impress_tests \ UITEST_TEST_NAME=tdf148810.Tdf148810.test_Tdf148810 Change-Id: I4aa62fe28ecbc483d5df0d1532fecd172afc54b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137569 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
parent
339d47a352
commit
f7b5eefc36
4 changed files with 63 additions and 28 deletions
|
@ -507,7 +507,7 @@ bool SvxUnoTextRangeBase::SetPropertyValueHelper( const SfxItemPropertyMapEntry*
|
|||
return !aValue.hasValue() || ((aValue >>= xRule) && !xRule.is());
|
||||
}
|
||||
|
||||
case WID_NUMLEVEL:
|
||||
case EE_PARA_OUTLLEVEL:
|
||||
{
|
||||
SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : nullptr;
|
||||
if(pForwarder && pSelection)
|
||||
|
@ -519,7 +519,8 @@ bool SvxUnoTextRangeBase::SetPropertyValueHelper( const SfxItemPropertyMapEntry*
|
|||
if(! pForwarder->SetDepth( pSelection->nStartPara, nLevel ) )
|
||||
throw lang::IllegalArgumentException();
|
||||
|
||||
return true;
|
||||
// If valid, then not yet finished. Also needs to be added to paragraph props.
|
||||
return nLevel < -1 || nLevel > 9;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -684,7 +685,7 @@ bool SvxUnoTextRangeBase::GetPropertyValueHelper( SfxItemSet const & rSet, cons
|
|||
}
|
||||
break;
|
||||
|
||||
case WID_NUMLEVEL:
|
||||
case EE_PARA_OUTLLEVEL:
|
||||
{
|
||||
SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : nullptr;
|
||||
if(pForwarder && pSelection)
|
||||
|
@ -976,7 +977,6 @@ beans::PropertyState SvxUnoTextRangeBase::_getPropertyState(const SfxItemPropert
|
|||
}
|
||||
break;
|
||||
|
||||
case WID_NUMLEVEL:
|
||||
case WID_NUMBERINGSTARTVALUE:
|
||||
case WID_PARAISNUMBERINGRESTART:
|
||||
eItemState = SfxItemState::SET;
|
||||
|
@ -1110,7 +1110,6 @@ bool SvxUnoTextRangeBase::_getOnePropertyStates(const SfxItemSet* pSet, const Sf
|
|||
}
|
||||
break;
|
||||
|
||||
case WID_NUMLEVEL:
|
||||
case WID_NUMBERINGSTARTVALUE:
|
||||
case WID_PARAISNUMBERINGRESTART:
|
||||
eItemState = SfxItemState::SET;
|
||||
|
@ -1215,12 +1214,6 @@ void SvxUnoTextRangeBase::_setPropertyToDefault(SvxTextForwarder* pForwarder, co
|
|||
{
|
||||
SvxUnoFontDescriptor::setPropertyToDefault( aSet );
|
||||
}
|
||||
else if( pMap->nWID == WID_NUMLEVEL )
|
||||
{
|
||||
// #101004# Call interface method instead of unsafe cast
|
||||
pForwarder->SetDepth( maSelection.nStartPara, -1 );
|
||||
return;
|
||||
}
|
||||
else if( pMap->nWID == WID_NUMBERINGSTARTVALUE )
|
||||
{
|
||||
pForwarder->SetNumberingStartValue( maSelection.nStartPara, -1 );
|
||||
|
@ -1263,7 +1256,7 @@ uno::Any SAL_CALL SvxUnoTextRangeBase::getPropertyDefault( const OUString& aProp
|
|||
case WID_FONTDESC:
|
||||
return SvxUnoFontDescriptor::getPropertyDefault( pPool );
|
||||
|
||||
case WID_NUMLEVEL:
|
||||
case EE_PARA_OUTLLEVEL:
|
||||
{
|
||||
uno::Any aAny;
|
||||
return aAny;
|
||||
|
@ -1969,8 +1962,8 @@ static void SvxPropertyValuesToItemSet(
|
|||
SfxItemSet &rItemSet,
|
||||
const uno::Sequence< beans::PropertyValue >& rPropertyValues,
|
||||
const SfxItemPropertySet *pPropSet,
|
||||
SvxTextForwarder *pForwarder /*needed for WID_NUMLEVEL*/,
|
||||
sal_Int32 nPara /*needed for WID_NUMLEVEL*/)
|
||||
SvxTextForwarder *pForwarder,
|
||||
sal_Int32 nPara)
|
||||
{
|
||||
for (const beans::PropertyValue& rProp : rPropertyValues)
|
||||
{
|
||||
|
@ -1993,18 +1986,6 @@ static void SvxPropertyValuesToItemSet(
|
|||
if (rProp.Value >>= aDesc)
|
||||
SvxUnoFontDescriptor::FillItemSet( aDesc, rItemSet );
|
||||
}
|
||||
else if (pEntry->nWID == WID_NUMLEVEL)
|
||||
{
|
||||
if (pForwarder)
|
||||
{
|
||||
sal_Int16 nLevel = -1;
|
||||
rProp.Value >>= nLevel;
|
||||
|
||||
// #101004# Call interface method instead of unsafe cast
|
||||
if (!pForwarder->SetDepth( nPara, nLevel ))
|
||||
throw lang::IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
else if (pEntry->nWID == WID_NUMBERINGSTARTVALUE )
|
||||
{
|
||||
if( pForwarder )
|
||||
|
|
|
@ -60,7 +60,6 @@ class SvxItemPropertySet;
|
|||
struct SfxItemPropertyMapEntry;
|
||||
|
||||
#define WID_FONTDESC OWN_ATTR_VALUE_START
|
||||
#define WID_NUMLEVEL OWN_ATTR_VALUE_START+1
|
||||
#define WID_PORTIONTYPE OWN_ATTR_VALUE_START+2
|
||||
#define WID_NUMBERINGSTARTVALUE OWN_ATTR_VALUE_START+3
|
||||
#define WID_PARAISNUMBERINGRESTART OWN_ATTR_VALUE_START+4
|
||||
|
@ -71,7 +70,7 @@ struct SfxItemPropertyMapEntry;
|
|||
|
||||
#define SVX_UNOEDIT_OUTLINER_PROPERTIES \
|
||||
SVX_UNOEDIT_NUMBERING_PROPERTY, \
|
||||
{ UNO_NAME_NUMBERING_LEVEL, WID_NUMLEVEL, ::cppu::UnoType<sal_Int16>::get(), 0, 0 }, \
|
||||
{ UNO_NAME_NUMBERING_LEVEL, EE_PARA_OUTLLEVEL, ::cppu::UnoType<sal_Int16>::get(), 0, 0 }, \
|
||||
{u"NumberingStartValue", WID_NUMBERINGSTARTVALUE, ::cppu::UnoType<sal_Int16>::get(), 0, 0 }, \
|
||||
{u"ParaIsNumberingRestart", WID_PARAISNUMBERINGRESTART, cppu::UnoType<bool>::get(), 0, 0 }
|
||||
|
||||
|
|
BIN
sd/qa/uitest/data/tdf148810_PARA_OUTLLEVEL.pptx
Normal file
BIN
sd/qa/uitest/data/tdf148810_PARA_OUTLLEVEL.pptx
Normal file
Binary file not shown.
55
sd/qa/uitest/impress_tests/tdf148810.py
Executable file
55
sd/qa/uitest/impress_tests/tdf148810.py
Executable file
|
@ -0,0 +1,55 @@
|
|||
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-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/.
|
||||
#
|
||||
|
||||
from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
|
||||
from libreoffice.uno.propertyvalue import mkPropertyValues
|
||||
from uitest.framework import UITestCase
|
||||
import time
|
||||
|
||||
|
||||
class Tdf148810(UITestCase):
|
||||
|
||||
def test_Tdf148810(self):
|
||||
with self.ui_test.load_file(get_url_for_data_file("tdf148810_PARA_OUTLLEVEL.pptx")):
|
||||
document = self.ui_test.get_component()
|
||||
|
||||
xDoc = self.xUITest.getTopFocusWindow()
|
||||
xEditWin = xDoc.getChild("impress_win")
|
||||
|
||||
xEditWin.executeAction("SELECT", mkPropertyValues({"OBJECT":"TextShape 2"}))
|
||||
|
||||
# type something to get into text editing mode (instead of shape selection).
|
||||
xEditWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
|
||||
#time.sleep(2)
|
||||
|
||||
# get to the front of the text (behind the bullet point)
|
||||
xEditWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "HOME"}))
|
||||
# remove the numbering bullet point
|
||||
xEditWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "BACKSPACE"}))
|
||||
|
||||
#xShape = xEditWin.getChild("TextShape 2")
|
||||
#print(xShape)
|
||||
#print(xShape.getChildren())
|
||||
#print(get_state_as_dict(xShape))
|
||||
#print(dir(xShape)
|
||||
|
||||
xText = document.DrawPages[0].getByIndex(1).createEnumeration().nextElement()
|
||||
#print(xText)
|
||||
# this is the first numbering level (as opposed to either -1 or None for no numbering)
|
||||
self.assertEqual(0, xText.NumberingLevel)
|
||||
#time.sleep(2)
|
||||
|
||||
self.xUITest.executeCommand(".uno:Undo")
|
||||
#time.sleep(2)
|
||||
|
||||
xText = document.DrawPages[0].getByIndex(1).createEnumeration().nextElement()
|
||||
# This was failing with "None"
|
||||
self.assertEqual(0, xText.NumberingLevel)
|
||||
|
||||
# vim: set shiftwidth=4 softtabstop=4 expandtab:
|
Loading…
Reference in a new issue