diff options
Diffstat (limited to 'svx/source/customshapes')
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShape2d.cxx | 72 | ||||
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShape2d.hxx | 5 | ||||
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShape3d.cxx | 16 | ||||
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShapeEngine.cxx | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx | 118 | ||||
-rw-r--r-- | svx/source/customshapes/tbxcustomshapes.cxx | 2 |
6 files changed, 121 insertions, 94 deletions
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index 16f48581bc..eba03cd9ea 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -33,7 +33,6 @@ #include "EnhancedCustomShape2d.hxx" #include "EnhancedCustomShapeGeometry.hxx" #include "EnhancedCustomShapeTypeNames.hxx" -#include "EnhancedCustomShapeFunctionParser.hxx" #include <svx/svdoashp.hxx> #include <svx/svdtrans.hxx> #include <svx/svdocirc.hxx> @@ -696,7 +695,16 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) : ClearItem( SDRATTR_TEXTDIRECTION ); //SJ: vertical writing is not required, by removing this item no outliner is created - // For primitive rendering, shadow handling is done completely based on the geometry, so i removed it here + // #i105323# For 2D AtoShapes, the shadow attirbute does not need to be applied to any + // of the constucted helper SdrObjects. This would lead to problems since the shadow + // of one helper object would fall on one helper object behind it (e.g. with the + // eyes of the smiley shape). This is not wanted; instead a single shadow 'behind' + // the AutoShape visualisation is wanted. This is done with primitive functionailty + // now in SdrCustomShapePrimitive2D::create2DDecomposition, but only for 2D objects + // (see there and in EnhancedCustomShape3d::Create3DObject to read more). + // This exception may be removed later when AutoShapes will create primitives directly. + // So, currently remove the ShadowAttribute from the ItemSet to not apply it to any + // 2D helper shape. ClearItem(SDRATTR_SHADOW); Point aP( pCustomShapeObj->GetSnapRect().Center() ); @@ -731,23 +739,23 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) : /*const sal_Int32* pDefData =*/ ApplyShapeAttributes( rGeometryItem ); switch( eSpType ) { - case mso_sptCan : nColorData = 0x20400000; break;
- case mso_sptCube : nColorData = 0x302e0000; break;
- case mso_sptActionButtonBlank : nColorData = 0x502ce400; break;
- case mso_sptActionButtonHome : nColorData = 0x702ce4ce; break;
- case mso_sptActionButtonHelp : nColorData = 0x602ce4c0; break;
- case mso_sptActionButtonInformation : nColorData = 0x702ce4c5; break;
- case mso_sptActionButtonBackPrevious : nColorData = 0x602ce4c0; break;
- case mso_sptActionButtonForwardNext : nColorData = 0x602ce4c0; break;
- case mso_sptActionButtonBeginning : nColorData = 0x602ce4c0; break;
- case mso_sptActionButtonEnd : nColorData = 0x602ce4c0; break;
- case mso_sptActionButtonReturn : nColorData = 0x602ce4c0; break;
- case mso_sptActionButtonDocument : nColorData = 0x702ce4ec; break;
- case mso_sptActionButtonSound : nColorData = 0x602ce4c0; break;
- case mso_sptActionButtonMovie : nColorData = 0x602ce4c0; break;
- case mso_sptBevel : nColorData = 0x502ce400; break;
- case mso_sptFoldedCorner : nColorData = 0x20e00000; break;
- case mso_sptSmileyFace : nColorData = 0x20e00000; break;
+ case mso_sptCan : nColorData = 0x20400000; break; + case mso_sptCube : nColorData = 0x302e0000; break; + case mso_sptActionButtonBlank : nColorData = 0x502ce400; break; + case mso_sptActionButtonHome : nColorData = 0x702ce4ce; break; + case mso_sptActionButtonHelp : nColorData = 0x602ce4c0; break; + case mso_sptActionButtonInformation : nColorData = 0x702ce4c5; break; + case mso_sptActionButtonBackPrevious : nColorData = 0x602ce4c0; break; + case mso_sptActionButtonForwardNext : nColorData = 0x602ce4c0; break; + case mso_sptActionButtonBeginning : nColorData = 0x602ce4c0; break; + case mso_sptActionButtonEnd : nColorData = 0x602ce4c0; break; + case mso_sptActionButtonReturn : nColorData = 0x602ce4c0; break; + case mso_sptActionButtonDocument : nColorData = 0x702ce4ec; break; + case mso_sptActionButtonSound : nColorData = 0x602ce4c0; break; + case mso_sptActionButtonMovie : nColorData = 0x602ce4c0; break; + case mso_sptBevel : nColorData = 0x502ce400; break; + case mso_sptFoldedCorner : nColorData = 0x20e00000; break; + case mso_sptSmileyFace : nColorData = 0x20e00000; break; case mso_sptNil : { if( sShapeType.getLength() > 4 && @@ -1701,19 +1709,19 @@ void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegm if(aNewB2DPolyPolygon.count()) { - if( !bLineGeometryNeededOnly )
- {
- // hack aNewB2DPolyPolygon to fill logic rect - this is
- // needed to produce gradient fills that look like mso
- aNewB2DPolygon.clear();
- aNewB2DPolygon.append(basegfx::B2DPoint(0,0));
- aNewB2DPolyPolygon.append(aNewB2DPolygon);
-
- aNewB2DPolygon.clear();
- aNewB2DPolygon.append(basegfx::B2DPoint(aLogicRect.GetWidth(),
- aLogicRect.GetHeight()));
- aNewB2DPolyPolygon.append(aNewB2DPolygon);
- }
+ if( !bLineGeometryNeededOnly ) + { + // hack aNewB2DPolyPolygon to fill logic rect - this is + // needed to produce gradient fills that look like mso + aNewB2DPolygon.clear(); + aNewB2DPolygon.append(basegfx::B2DPoint(0,0)); + aNewB2DPolyPolygon.append(aNewB2DPolygon); + + aNewB2DPolygon.clear(); + aNewB2DPolygon.append(basegfx::B2DPoint(aLogicRect.GetWidth(), + aLogicRect.GetHeight())); + aNewB2DPolyPolygon.append(aNewB2DPolygon); + } // #i37011# bool bForceCreateTwoObjects(false); diff --git a/svx/source/customshapes/EnhancedCustomShape2d.hxx b/svx/source/customshapes/EnhancedCustomShape2d.hxx index e8f40b49dd..ffacbfa59c 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.hxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.hxx @@ -36,13 +36,13 @@ #include <com/sun/star/uno/Sequence.h> #include <com/sun/star/beans/PropertyValues.hpp> #include <com/sun/star/awt/Point.hpp> -#include <svtools/itemset.hxx> +#include <svl/itemset.hxx> #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeParameter.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp> -#include <EnhancedCustomShapeFunctionParser.hxx> +#include <svx/EnhancedCustomShapeFunctionParser.hxx> #include <boost/shared_ptr.hpp> #include <vector> @@ -52,6 +52,7 @@ #define DFF_CUSTOMSHAPE_EXCH 4 class SdrModel; +class SdrObject; class SfxItemSet; struct SvxMSDffVertPair; struct SvxMSDffCalculationData; diff --git a/svx/source/customshapes/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx index ed94bcf075..fcce0b5a0e 100644 --- a/svx/source/customshapes/EnhancedCustomShape3d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape3d.cxx @@ -37,8 +37,8 @@ #include <svditer.hxx> #include <svx/svdobj.hxx> #include <svx/svdoashp.hxx> -#include <svtools/poolitem.hxx> -#include <svtools/itemset.hxx> +#include <svl/poolitem.hxx> +#include <svl/itemset.hxx> #include <svx/xfillit0.hxx> #include <svx/xsflclit.hxx> #include <svx/xit.hxx> @@ -323,7 +323,17 @@ SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, con Point aCenter( aSnapRect.Center() ); SfxItemSet aSet( pCustomShape->GetMergedItemSet() ); - aSet.ClearItem( SDRATTR_TEXTDIRECTION ); //SJ: vertical writing is not required, by removing this item no outliner is created + + //SJ: vertical writing is not required, by removing this item no outliner is created + aSet.ClearItem( SDRATTR_TEXTDIRECTION ); + + // #i105323# For 3D AutoShapes, the shadow attribute has to be applied to each + // created visualisation helper model shape individually. The shadow itself + // will then be rendered from the 3D renderer correctly for the whole 3D scene + // (and thus behind all objects of which the visualisation may be built). So, + // dio NOT remove it from the ItemSet here. + // aSet.ClearItem(SDRATTR_SHADOW); + std::vector< E3dCompoundObject* > aPlaceholderObjectList; double fExtrusionBackward, fExtrusionForward; diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx index 2fad91e12e..1ce09428f0 100644 --- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx @@ -48,7 +48,7 @@ #include <svx/outlobj.hxx> #include <svx/outliner.hxx> #include <svx/svdoutl.hxx> -#include <svtools/itemset.hxx> +#include <svl/itemset.hxx> #include <svx/svdopath.hxx> #include <svx/svdpage.hxx> #include <svx/svdmodel.hxx> diff --git a/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx b/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx index d9db4812e8..9c408f7746 100644..100755 --- a/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -30,15 +30,15 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#include "EnhancedCustomShapeFunctionParser.hxx" #include "EnhancedCustomShape2d.hxx" #include <rtl/ustring.hxx> #include <tools/fract.hxx> -// Makes parser a static resource, +// Makes parser a static resource, // we're synchronized externally. // But watch out, the parser might have // state not visible to this code! + #define BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE #if defined(VERBOSE) && defined(DBG_UTIL) #include <typeinfo> @@ -160,7 +160,7 @@ public: AdjustmentExpression( const EnhancedCustomShape2d& rCustoShape, sal_Int32 nIndex ) : mnIndex ( nIndex ) , mrCustoShape( rCustoShape ) - + { } virtual double operator()() const @@ -336,7 +336,7 @@ public: virtual double operator()() const { return getValue( meFunct, mpArg ); - } + } virtual bool isConstant() const { return mpArg->isConstant(); @@ -507,7 +507,7 @@ public: virtual double operator()() const { return getValue( meFunct, mpFirstArg, mpSecondArg ); - } + } virtual bool isConstant() const { return mpFirstArg->isConstant() && mpSecondArg->isConstant(); @@ -559,7 +559,7 @@ public: FillEquationParameter( mpSecondArg->fillNode( rEquations, NULL, nFlags &~EXPRESSION_FLAG_SUMANGLE_MODE ), 1, aSumangle2 ); aRet.Type = EnhancedCustomShapeParameterType::EQUATION; aRet.Value <<= (sal_Int32)rEquations.size(); - rEquations.push_back( aSumangle2 ); + rEquations.push_back( aSumangle2 ); EnhancedCustomShapeEquation aEquation; aEquation.nOperation |= 0; @@ -592,7 +592,7 @@ public: } } break; - case BINARY_FUNC_MINUS: + case BINARY_FUNC_MINUS: { EnhancedCustomShapeEquation aEquation; aEquation.nOperation |= 0; @@ -655,7 +655,7 @@ public: rEquations.push_back( aEquation ); } break; - case BINARY_FUNC_MIN : + case BINARY_FUNC_MIN : { EnhancedCustomShapeEquation aEquation; aEquation.nOperation |= 4; @@ -713,9 +713,9 @@ public: } virtual bool isConstant() const { - return - mpFirstArg->isConstant() && - mpSecondArg->isConstant() && + return + mpFirstArg->isConstant() && + mpSecondArg->isConstant() && mpThirdArg->isConstant(); } virtual double operator()() const @@ -849,7 +849,7 @@ class UnaryFunctionFunctor ParserContextSharedPtr mpContext; public : - + UnaryFunctionFunctor( const ExpressionFunct eFunct, const ParserContextSharedPtr& rContext ) : meFunct( eFunct ), mpContext( rContext ) @@ -878,7 +878,7 @@ public : @tpl Generator Generator functor, to generate an ExpressionNode of appropriate type - + */ class BinaryFunctionFunctor { @@ -953,13 +953,13 @@ public : // Workaround for MSVC compiler anomaly (stack trashing) // -// The default ureal_parser_policies implementation of parse_exp -// triggers a really weird error in MSVC7 (Version 13.00.9466), in -// that the real_parser_impl::parse_main() call of parse_exp() +// The default ureal_parser_policies implementation of parse_exp +// triggers a really weird error in MSVC7 (Version 13.00.9466), in +// that the real_parser_impl::parse_main() call of parse_exp() // overwrites the frame pointer _on the stack_ (EBP of the calling -// function gets overwritten while lying on the stack). +// function gets overwritten while lying on the stack). // -// For the time being, our parser thus can only read the 1.0E10 +// For the time being, our parser thus can only read the 1.0E10 // notation, not the 1.0e10 one. // // TODO(F1): Also handle the 1.0e10 case here. @@ -968,9 +968,9 @@ template< typename T > struct custom_real_parser_policies : public ::boost::spir template< typename ScannerT > static typename ::boost::spirit::parser_result< ::boost::spirit::chlit<>, ScannerT >::type parse_exp(ScannerT& scan) - { + { // as_lower_d somehow breaks MSVC7 - return ::boost::spirit::ch_p('E').parse(scan); + return ::boost::spirit::ch_p('E').parse(scan); } }; @@ -978,29 +978,30 @@ template< typename T > struct custom_real_parser_policies : public ::boost::spir less literally written down below, only slightly obfuscated by the parser actions): - identifier = '$'|'pi'|'e'|'X'|'Y'|'Width'|'Height' - + identifier = '$'|'pi'|'e'|'X'|'Y'|'Width'|'Height' + function = 'abs'|'sqrt'|'sin'|'cos'|'tan'|'atan'|'acos'|'asin'|'exp'|'log' - basic_expression = - number | - identifier | - function '(' additive_expression ')' | - '(' additive_expression ')' - - unary_expression = + basic_expression = + number | + identifier | + function '(' additive_expression ')' | + '(' additive_expression ')' + + unary_expression = '-' basic_expression | basic_expression - - multiplicative_expression = - unary_expression ( ( '*' unary_expression )* | + + multiplicative_expression = + unary_expression ( ( '*' unary_expression )* | ( '/' unary_expression )* ) - - additive_expression = - multiplicative_expression ( ( '+' multiplicative_expression )* | - ( '-' multiplicative_expression )* ) + + additive_expression = + multiplicative_expression ( ( '+' multiplicative_expression )* | + ( '-' multiplicative_expression )* ) */ + class ExpressionGrammar : public ::boost::spirit::grammar< ExpressionGrammar > { public: @@ -1042,7 +1043,7 @@ public: | str_p( "logheight" )[ EnumFunctor(ENUM_FUNC_LOGHEIGHT, self.getContext() ) ] ; - unaryFunction = + unaryFunction = (str_p( "abs" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( UNARY_FUNC_ABS, self.getContext()) ] | (str_p( "sqrt" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( UNARY_FUNC_SQRT, self.getContext()) ] | (str_p( "sin" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( UNARY_FUNC_SIN, self.getContext()) ] @@ -1051,17 +1052,17 @@ public: | (str_p( "atan" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( UNARY_FUNC_ATAN, self.getContext()) ] ; - binaryFunction = + binaryFunction = (str_p( "min" ) >> '(' >> additiveExpression >> ',' >> additiveExpression >> ')' )[ BinaryFunctionFunctor( BINARY_FUNC_MIN, self.getContext()) ] | (str_p( "max" ) >> '(' >> additiveExpression >> ',' >> additiveExpression >> ')' )[ BinaryFunctionFunctor( BINARY_FUNC_MAX, self.getContext()) ] | (str_p( "atan2") >> '(' >> additiveExpression >> ',' >> additiveExpression >> ')' )[ BinaryFunctionFunctor( BINARY_FUNC_ATAN2,self.getContext()) ] ; - ternaryFunction = + ternaryFunction = (str_p( "if" ) >> '(' >> additiveExpression >> ',' >> additiveExpression >> ',' >> additiveExpression >> ')' )[ IfFunctor( self.getContext() ) ] ; - funcRef_decl = + funcRef_decl = lexeme_d[ +( range_p('a','z') | range_p('A','Z') | range_p('0','9') ) ]; functionReference = @@ -1073,7 +1074,7 @@ public: modifierReference = (str_p( "$" ) >> modRef_decl )[ EnumFunctor( ENUM_FUNC_ADJUSTMENT, self.getContext() ) ]; - basicExpression = + basicExpression = real_parser<double, custom_real_parser_policies<double> >()[ DoubleConstantFunctor(self.getContext()) ] | identifier | functionReference @@ -1084,19 +1085,19 @@ public: | '(' >> additiveExpression >> ')' ; - unaryExpression = + unaryExpression = ('-' >> basicExpression)[ UnaryFunctionFunctor( UNARY_FUNC_NEG, self.getContext()) ] | basicExpression ; - multiplicativeExpression = + multiplicativeExpression = unaryExpression >> *( ('*' >> unaryExpression)[ BinaryFunctionFunctor( BINARY_FUNC_MUL, self.getContext()) ] | ('/' >> unaryExpression)[ BinaryFunctionFunctor( BINARY_FUNC_DIV, self.getContext()) ] ) ; - additiveExpression = + additiveExpression = multiplicativeExpression >> *( ('+' >> multiplicativeExpression)[ BinaryFunctionFunctor( BINARY_FUNC_PLUS, self.getContext()) ] | ('-' >> multiplicativeExpression)[ BinaryFunctionFunctor( BINARY_FUNC_MINUS, self.getContext()) ] @@ -1117,9 +1118,9 @@ public: { return additiveExpression; } - + private: - // the constituents of the Spirit arithmetic expression grammar. + // the constituents of the Spirit arithmetic expression grammar. // For the sake of readability, without 'ma' prefix. ::boost::spirit::rule< ScannerT > additiveExpression; ::boost::spirit::rule< ScannerT > multiplicativeExpression; @@ -1133,7 +1134,7 @@ public: ::boost::spirit::rule< ScannerT > modRef_decl; ::boost::spirit::rule< ScannerT > modifierReference; ::boost::spirit::rule< ScannerT > identifier; - }; + }; const ParserContextSharedPtr& getContext() const { @@ -1143,13 +1144,13 @@ public: private: ParserContextSharedPtr mpParserContext; // might get modified during parsing }; - + #ifdef BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE const ParserContextSharedPtr& getParserContext() { static ParserContextSharedPtr lcl_parserContext( new ParserContext() ); - // clear node stack (since we reuse the static object, that's + // clear node stack (since we reuse the static object, that's // the whole point here) while( !lcl_parserContext->maOperandStack.empty() ) lcl_parserContext->maOperandStack.pop(); @@ -1162,12 +1163,14 @@ const ParserContextSharedPtr& getParserContext() namespace EnhancedCustomShape { + + ExpressionNodeSharedPtr FunctionParser::parseFunction( const ::rtl::OUString& rFunction, const EnhancedCustomShape2d& rCustoShape ) { - // TODO(Q1): Check if a combination of the RTL_UNICODETOTEXT_FLAGS_* - // gives better conversion robustness here (we might want to map space + // TODO(Q1): Check if a combination of the RTL_UNICODETOTEXT_FLAGS_* + // gives better conversion robustness here (we might want to map space // etc. to ASCII space here) - const ::rtl::OString& rAsciiFunction( + const ::rtl::OString& rAsciiFunction( rtl::OUStringToOString( rFunction, RTL_TEXTENCODING_ASCII_US ) ); StringIteratorT aStart( rAsciiFunction.getStr() ); @@ -1185,23 +1188,28 @@ ExpressionNodeSharedPtr FunctionParser::parseFunction( const ::rtl::OUString& rF pContext->mpCustoShape = &rCustoShape; ExpressionGrammar aExpressionGrammer( pContext ); - const ::boost::spirit::parse_info<StringIteratorT> aParseInfo( + const ::boost::spirit::parse_info<StringIteratorT> aParseInfo( ::boost::spirit::parse( aStart, aEnd, aExpressionGrammer >> ::boost::spirit::end_p, ::boost::spirit::space_p ) ); OSL_DEBUG_ONLY(::std::cout.flush()); // needed to keep stdout and cout in sync + + // input fully congested by the parser? if( !aParseInfo.full ) throw ParseError( "EnhancedCustomShapeFunctionParser::parseFunction(): string not fully parseable" ); - // parser's state stack now must contain exactly _one_ ExpressionNode, + // parser's state stack now must contain exactly _one_ ExpressionNode, // which represents our formula. if( pContext->maOperandStack.size() != 1 ) throw ParseError( "EnhancedCustomShapeFunctionParser::parseFunction(): incomplete or empty expression" ); + return pContext->maOperandStack.top(); } + } + diff --git a/svx/source/customshapes/tbxcustomshapes.cxx b/svx/source/customshapes/tbxcustomshapes.cxx index a663bc6fcf..c1561822cf 100644 --- a/svx/source/customshapes/tbxcustomshapes.cxx +++ b/svx/source/customshapes/tbxcustomshapes.cxx @@ -37,7 +37,7 @@ #include <svx/svxids.hrc> #endif #include <tools/shl.hxx> -#include <svtools/eitem.hxx> +#include <svl/eitem.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/viewsh.hxx> #include <sfx2/viewfrm.hxx> |