Kaydet (Commit) a08c833a authored tarafından Tamas Bunth's avatar Tamas Bunth Kaydeden (comit) Tamás Bunth

Use base class to set/get super/sub script

Looks like some obsolete code

Change-Id: If600609ccd0baf3c10261cc850ac5ddc3c046401
Reviewed-on: https://gerrit.libreoffice.org/39216Reviewed-by: 's avatarTamás Bunth <btomi96@gmail.com>
Tested-by: 's avatarTamás Bunth <btomi96@gmail.com>
üst 99cde723
......@@ -58,165 +58,6 @@ ScVbaFont::~ScVbaFont()
{
}
/// @throws css::uno::RuntimeException
static uno::Reference< beans::XPropertySet > lcl_TextProperties( uno::Reference< table::XCell >& xIf )
{
uno::Reference< text::XTextRange > xTxtRange( xIf, uno::UNO_QUERY_THROW );
uno::Reference< text::XSimpleText > xTxt( xTxtRange->getText(), uno::UNO_QUERY_THROW ) ;
uno::Reference< beans::XPropertySet > xProps( xTxt->createTextCursor(), uno::UNO_QUERY_THROW );
return xProps;
}
void SAL_CALL
ScVbaFont::setSuperscript( const uno::Any& aValue )
{
// #FIXEME create some sort of generic get/set code where
// you can pass a functor
// get/set - Super/sub script code is exactly the same
// except for the call applied at each cell position
uno::Reference< table::XCell> xCell( mxFont, uno::UNO_QUERY );
uno::Reference< table::XCellRange > xCellRange( mxFont, uno::UNO_QUERY );
if ( !xCell.is() )
{
uno::Reference< table::XColumnRowRange > xColumnRowRange(xCellRange, uno::UNO_QUERY_THROW );
sal_Int32 nCols = xColumnRowRange->getColumns()->getCount();
sal_Int32 nRows = xColumnRowRange->getRows()->getCount();
for ( sal_Int32 col = 0; col < nCols; ++col )
{
for ( sal_Int32 row = 0; row < nRows; ++row )
{
uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ) , uno::UNO_QUERY_THROW );
rtl::Reference< ScVbaFont > aFont( new ScVbaFont( getParent(), mxContext, mPalette, xProps ) );
aFont->setSuperscript( aValue );
}
}
return;
}
xCell.set( xCellRange->getCellByPosition( 0,0 ) );
uno::Reference< beans::XPropertySet > xProps = lcl_TextProperties( xCell );
bool bValue = false;
aValue >>= bValue;
sal_Int16 nValue = NORMAL;
sal_Int8 nValue2 = NORMALHEIGHT;
if( bValue )
{
nValue = SUPERSCRIPT;
nValue2 = SUPERSCRIPTHEIGHT;
}
xProps->setPropertyValue("CharEscapement", uno::Any(nValue) );
xProps->setPropertyValue("CharEscapementHeight", uno::Any(nValue2) );
}
uno::Any SAL_CALL
ScVbaFont::getSuperscript()
{
uno::Reference< table::XCell> xCell( mxFont, uno::UNO_QUERY );
uno::Reference< table::XCellRange > xCellRange( mxFont, uno::UNO_QUERY );
if ( !xCell.is() )
{
uno::Reference< table::XColumnRowRange > xColumnRowRange(xCellRange, uno::UNO_QUERY_THROW );
sal_Int32 nCols = xColumnRowRange->getColumns()->getCount();
sal_Int32 nRows = xColumnRowRange->getRows()->getCount();
uno::Any aRes;
for ( sal_Int32 col = 0; col < nCols; ++col )
{
for ( sal_Int32 row = 0; row < nRows; ++row )
{
uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ), uno::UNO_QUERY_THROW );
rtl::Reference< ScVbaFont > aFont( new ScVbaFont( getParent(), mxContext, mPalette, xProps ) );
if ( !col && !row )
aRes = aFont->getSuperscript();
else if ( aRes != aFont->getSuperscript() )
return aNULL();
}
}
return aRes;
}
xCell.set( xCellRange->getCellByPosition( 0,0 ) );
uno::Reference< beans::XPropertySet > xProps = lcl_TextProperties( xCell );
short nValue = 0;
xProps->getPropertyValue("CharEscapement") >>= nValue;
return uno::makeAny( ( nValue == SUPERSCRIPT ) );
}
void SAL_CALL
ScVbaFont::setSubscript( const uno::Any& aValue )
{
uno::Reference< table::XCell> xCell( mxFont, uno::UNO_QUERY );
uno::Reference< table::XCellRange > xCellRange( mxFont, uno::UNO_QUERY );
if ( !xCell.is() )
{
uno::Reference< table::XColumnRowRange > xColumnRowRange(xCellRange, uno::UNO_QUERY_THROW );
sal_Int32 nCols = xColumnRowRange->getColumns()->getCount();
sal_Int32 nRows = xColumnRowRange->getRows()->getCount();
for ( sal_Int32 col = 0; col < nCols; ++col )
{
for ( sal_Int32 row = 0; row < nRows; ++row )
{
uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ) , uno::UNO_QUERY_THROW );
rtl::Reference< ScVbaFont > aFont( new ScVbaFont( getParent(), mxContext, mPalette, xProps ) );
aFont->setSubscript( aValue );
}
}
return;
}
xCell.set( xCellRange->getCellByPosition( 0,0 ) );
uno::Reference< beans::XPropertySet > xProps = lcl_TextProperties( xCell );
bool bValue = false;
aValue >>= bValue;
sal_Int16 nValue = NORMAL;
sal_Int8 nValue2 = NORMALHEIGHT;
if( bValue )
{
nValue= SUBSCRIPT;
nValue2 = SUBSCRIPTHEIGHT;
}
xProps->setPropertyValue("CharEscapementHeight", uno::Any(nValue2) );
xProps->setPropertyValue("CharEscapement", uno::Any(nValue) );
}
uno::Any SAL_CALL
ScVbaFont::getSubscript()
{
uno::Reference< table::XCell> xCell( mxFont, uno::UNO_QUERY );
uno::Reference< table::XCellRange > xCellRange( mxFont, uno::UNO_QUERY );
if ( !xCell.is() )
{
uno::Reference< table::XColumnRowRange > xColumnRowRange(xCellRange, uno::UNO_QUERY_THROW );
sal_Int32 nCols = xColumnRowRange->getColumns()->getCount();
sal_Int32 nRows = xColumnRowRange->getRows()->getCount();
uno::Any aRes;
for ( sal_Int32 col = 0; col < nCols; ++col )
{
for ( sal_Int32 row = 0; row < nRows; ++row )
{
uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ), uno::UNO_QUERY_THROW );
rtl::Reference< ScVbaFont > aFont( new ScVbaFont( getParent(), mxContext, mPalette, xProps ) );
if ( !col && !row )
aRes = aFont->getSubscript();
else if ( aRes != aFont->getSubscript() )
return aNULL();
}
}
return aRes;
}
xCell.set( xCellRange->getCellByPosition( 0,0 ) );
uno::Reference< beans::XPropertySet > xProps = lcl_TextProperties( xCell );
short nValue = NORMAL;
xProps->getPropertyValue("CharEscapement") >>= nValue;
return uno::makeAny( ( nValue == SUBSCRIPT ) );
}
uno::Any SAL_CALL
ScVbaFont::getSize()
{
......
......@@ -62,10 +62,6 @@ public:
virtual css::uno::Any SAL_CALL getStrikethrough() override;
virtual css::uno::Any SAL_CALL getShadow() override;
virtual css::uno::Any SAL_CALL getItalic() override;
virtual css::uno::Any SAL_CALL getSubscript() override;
virtual void SAL_CALL setSubscript( const css::uno::Any& _subscript ) override;
virtual css::uno::Any SAL_CALL getSuperscript() override;
virtual void SAL_CALL setSuperscript( const css::uno::Any& _superscript ) override;
virtual css::uno::Any SAL_CALL getName() override;
virtual css::uno::Any SAL_CALL getColor() override ;
virtual css::uno::Any SAL_CALL getOutlineFont() override ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment