diff options
author | Michael Brauer <mib@openoffice.org> | 2001-01-15 10:28:36 +0000 |
---|---|---|
committer | Michael Brauer <mib@openoffice.org> | 2001-01-15 10:28:36 +0000 |
commit | f436f36ea43f05a9e25bfdf1c2c6ab33ceca89cc (patch) | |
tree | f78a7d12ff5c05886c0265fe9e14210b9b7e736f /xmloff | |
parent | 9f55147829ec63c7e872f9037d118e6fc8c0e6bd (diff) |
#81708#: new frame size properties and XML attributes
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/text/XMLTextFrameContext.cxx | 175 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextFrameContext.hxx | 7 | ||||
-rw-r--r-- | xmloff/source/text/txtexppr.cxx | 79 | ||||
-rw-r--r-- | xmloff/source/text/txtimp.cxx | 7 | ||||
-rw-r--r-- | xmloff/source/text/txtimppr.cxx | 51 | ||||
-rw-r--r-- | xmloff/source/text/txtparae.cxx | 137 | ||||
-rw-r--r-- | xmloff/source/text/txtprhdl.cxx | 120 | ||||
-rw-r--r-- | xmloff/source/text/txtprmap.cxx | 23 |
8 files changed, 387 insertions, 212 deletions
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index 4ccba97a3acf..0f73e4f9e9fb 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLTextFrameContext.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: mib $ $Date: 2001-01-03 11:07:00 $ + * last change: $Author: mib $ $Date: 2001-01-15 11:28:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -315,7 +315,8 @@ XMLTextFrameContext::XMLTextFrameContext( sHeight(RTL_CONSTASCII_USTRINGPARAM("Height")), sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight")), sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType")), - sSizeRelative(RTL_CONSTASCII_USTRINGPARAM("SizeRelative")), + sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight")), + sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth")), sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")), sVertOrientPosition(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")), sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName")), @@ -339,19 +340,18 @@ XMLTextFrameContext::XMLTextFrameContext( sal_Int32 nX = 0; sal_Int32 nY = 0; sal_Int32 nWidth = 0; - sal_Int32 nMinWidth = 0; sal_Int32 nHeight = 0; - sal_Int32 nMinHeight = 0; + sal_Int8 nRelWidth = 0; + sal_Int8 nRelHeight = 0; sal_Int32 nZIndex = -1; sal_Int16 nPage = 0; sal_Int16 nRotation = 0; TextContentAnchorType eAnchorType = eATyp; - sal_Bool bRelWidth = sal_False; - sal_Bool bRelMinWidth = sal_False; - sal_Bool bRelHeight = sal_False; - sal_Bool bRelMinHeight = sal_False; + sal_Bool bMinHeight = sal_False; + sal_Bool bSyncWidth = sal_False; + sal_Bool bSyncHeight = sal_False; UniReference < XMLTextImportHelper > xTxtImport = GetImport().GetTextImport(); const SvXMLTokenMap& rTokenMap = @@ -404,32 +404,81 @@ XMLTextFrameContext::XMLTextFrameContext( GetImport().GetMM100UnitConverter().convertMeasure( nY, rValue ); break; case XML_TOK_TEXT_FRAME_WIDTH: - bRelWidth = rValue.indexOf( '%' ) != -1; - if( bRelWidth ) - GetImport().GetMM100UnitConverter().convertPercent( nWidth, rValue ); + // relative widths are obsolete since SRC617. Remove them some day! + if( rValue.indexOf( '%' ) != -1 ) + { + sal_Int32 nTmp; + GetImport().GetMM100UnitConverter().convertPercent( nTmp, + rValue ); + nRelWidth = (sal_Int8)nTmp; + } else - GetImport().GetMM100UnitConverter().convertMeasure( nWidth, rValue, 0 ); + { + GetImport().GetMM100UnitConverter().convertMeasure( nWidth, + rValue, 0 ); + } break; - case XML_TOK_TEXT_FRAME_MIN_WIDTH: - bRelMinWidth = rValue.indexOf( '%' ) != -1; - if( bRelMinWidth ) - GetImport().GetMM100UnitConverter().convertPercent( nMinWidth, rValue ); + case XML_TOK_TEXT_FRAME_REL_WIDTH: + if( rValue.equalsAsciiL( sXML_scale, sizeof(sXML_scale)-1 ) ) + { + bSyncWidth = sal_True; + } else - GetImport().GetMM100UnitConverter().convertMeasure( nMinWidth, rValue, 0 ); + { + sal_Int32 nTmp; + if( GetImport().GetMM100UnitConverter(). + convertPercent( nTmp, rValue ) ) + nRelWidth = (sal_Int8)nTmp; + } break; case XML_TOK_TEXT_FRAME_HEIGHT: - bRelHeight = rValue.indexOf( '%' ) != -1; - if( bRelHeight ) - GetImport().GetMM100UnitConverter().convertPercent( nHeight, rValue ); + // relative heights are obsolete since SRC617. Remove them some day! + if( rValue.indexOf( '%' ) != -1 ) + { + sal_Int32 nTmp; + GetImport().GetMM100UnitConverter().convertPercent( nTmp, + rValue ); + nRelHeight = (sal_Int8)nTmp; + } + else + { + GetImport().GetMM100UnitConverter().convertMeasure( nHeight, + rValue, 0 ); + } + break; + case XML_TOK_TEXT_FRAME_REL_HEIGHT: + if( rValue.equalsAsciiL( sXML_scale, sizeof(sXML_scale)-1 ) ) + { + bSyncHeight = sal_True; + } + else if( rValue.equalsAsciiL( sXML_scale_min, + sizeof(sXML_scale_min)-1 ) ) + { + bSyncHeight = sal_True; + bMinHeight = sal_True; + } else - GetImport().GetMM100UnitConverter().convertMeasure( nHeight, rValue, 0 ); + { + sal_Int32 nTmp; + if( GetImport().GetMM100UnitConverter(). + convertPercent( nTmp, rValue ) ) + nRelHeight = (sal_Int8)nTmp; + } break; case XML_TOK_TEXT_FRAME_MIN_HEIGHT: - bRelMinHeight = rValue.indexOf( '%' ) != -1; - if( bRelMinHeight ) - GetImport().GetMM100UnitConverter().convertPercent( nMinHeight, rValue ); + if( rValue.indexOf( '%' ) != -1 ) + { + sal_Int32 nTmp; + GetImport().GetMM100UnitConverter().convertPercent( nTmp, + rValue ); + nRelHeight = (sal_Int8)nTmp; + } else - GetImport().GetMM100UnitConverter().convertMeasure( nMinHeight, rValue, 0 ); + { + GetImport().GetMM100UnitConverter().convertMeasure( nHeight, + rValue, 0 ); + } + bMinHeight = sal_True; break; case XML_TOK_TEXT_FRAME_Z_INDEX: GetImport().GetMM100UnitConverter().convertNumber( nZIndex, rValue, -1 ); @@ -560,63 +609,45 @@ XMLTextFrameContext::XMLTextFrameContext( xPropSet->setPropertyValue( sVertOrientPosition, aAny ); // width - if( !nWidth ) + if( nWidth > 0 ) { - nWidth = nMinWidth; - bRelWidth = bRelMinWidth; + aAny <<= nWidth; + xPropSet->setPropertyValue( sWidth, aAny ); } - sal_Bool bMinHeight = sal_False; - if( !nHeight ) + if( nRelWidth > 0 || nWidth > 0 ) { - nHeight = nMinHeight; - bRelHeight = bRelMinHeight; - bMinHeight = sal_True; + aAny <<= nRelWidth; + xPropSet->setPropertyValue( sRelativeWidth, aAny ); } - if( nWidth ) + if( bSyncWidth || nWidth > 0 ) { - if( bRelWidth > 0 ) - { - aAny <<= (sal_Int8)nWidth; - xPropSet->setPropertyValue( sRelativeWidth, aAny ); - } - else - { - aAny <<= nWidth; - xPropSet->setPropertyValue( sWidth, aAny ); - } - } - else if( XML_TEXT_FRAME_GRAPHIC == nType && nHeight > 0 ) - { - // TODO: synchronize width to height + aAny.setValue( &bSyncWidth, ::getBooleanCppuType() ); + xPropSet->setPropertyValue( sIsSyncWidthToHeight, aAny ); } if( nHeight > 0 ) { - if( xPropSetInfo->hasPropertyByName( sSizeType ) ) - { - sal_Int16 nSizeType = - (bMinHeight && XML_TEXT_FRAME_TEXTBOX == nType) ? SizeType::MIN - : SizeType::FIX; - aAny <<= nSizeType; - xPropSet->setPropertyValue( sSizeType, aAny ); - } - if( bRelHeight > 0 ) - { - aAny <<= (sal_Int8)nHeight; - xPropSet->setPropertyValue( sRelativeHeight, aAny ); - } - else - { - aAny <<= nHeight; - xPropSet->setPropertyValue( sHeight, aAny ); - } + aAny <<= nHeight; + xPropSet->setPropertyValue( sHeight, aAny ); + } + if( nRelHeight > 0 || nHeight > 0 ) + { + aAny <<= nRelHeight; + xPropSet->setPropertyValue( sRelativeHeight, aAny ); + } + if( bSyncHeight || nHeight > 0 ) + { + aAny.setValue( &bSyncHeight, ::getBooleanCppuType() ); + xPropSet->setPropertyValue( sIsSyncHeightToWidth, aAny ); } - else if( XML_TEXT_FRAME_GRAPHIC == nType && nWidth > 0 ) + if( xPropSetInfo->hasPropertyByName( sSizeType ) && bMinHeight || + nHeight > 0 || nRelHeight > 0 ) { - // synchroize height to width - sal_Bool bTmp = sal_True; - aAny.setValue( &bTmp, ::getBooleanCppuType() ); - xPropSet->setPropertyValue( sSizeRelative, aAny ); + sal_Int16 nSizeType = + (bMinHeight && XML_TEXT_FRAME_TEXTBOX == nType) ? SizeType::MIN + : SizeType::FIX; + aAny <<= nSizeType; + xPropSet->setPropertyValue( sSizeType, aAny ); } if( XML_TEXT_FRAME_GRAPHIC == nType ) diff --git a/xmloff/source/text/XMLTextFrameContext.hxx b/xmloff/source/text/XMLTextFrameContext.hxx index 8f1162d361d8..c62ccfa84aae 100644 --- a/xmloff/source/text/XMLTextFrameContext.hxx +++ b/xmloff/source/text/XMLTextFrameContext.hxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLTextFrameContext.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: mib $ $Date: 2000-12-18 13:25:02 $ + * last change: $Author: mib $ $Date: 2001-01-15 11:28:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -92,7 +92,8 @@ class XMLTextFrameContext : public SvXMLImportContext const ::rtl::OUString sHeight; const ::rtl::OUString sRelativeHeight; const ::rtl::OUString sSizeType; - const ::rtl::OUString sSizeRelative; + const ::rtl::OUString sIsSyncWidthToHeight; + const ::rtl::OUString sIsSyncHeightToWidth; const ::rtl::OUString sHoriOrientPosition; const ::rtl::OUString sVertOrientPosition; const ::rtl::OUString sChainNextName; diff --git a/xmloff/source/text/txtexppr.cxx b/xmloff/source/text/txtexppr.cxx index ef696efb9e5d..c71eda2dc87e 100644 --- a/xmloff/source/text/txtexppr.cxx +++ b/xmloff/source/text/txtexppr.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtexppr.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: cl $ $Date: 2000-12-05 22:28:33 $ + * last change: $Author: mib $ $Date: 2001-01-15 11:28:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -385,17 +385,12 @@ void XMLTextExportPropertySetMapper::ContextFilter( XMLPropertyState* pTopBorderState = NULL; XMLPropertyState* pBottomBorderState = NULL; - // filter width/height properties - XMLPropertyState* pWidthAbsState = NULL; - XMLPropertyState* pWidthMinAbsState = NULL; - XMLPropertyState* pWidthRelState = NULL; - XMLPropertyState* pWidthMinRelState = NULL; - XMLPropertyState* pHeightAbsState = NULL; + // filter height properties XMLPropertyState* pHeightMinAbsState = NULL; - XMLPropertyState* pHeightRelState = NULL; XMLPropertyState* pHeightMinRelState = NULL; + XMLPropertyState* pHeightAbsState = NULL; + XMLPropertyState* pHeightRelState = NULL; XMLPropertyState* pSizeTypeState = NULL; - XMLPropertyState* pSyncHeightState = NULL; // wrap XMLPropertyState* pWrapState = NULL; @@ -469,14 +464,11 @@ void XMLTextExportPropertySetMapper::ContextFilter( case CTF_TOPBORDER: pTopBorderState = propertie; break; case CTF_BOTTOMBORDER: pBottomBorderState = propertie; break; - case CTF_FRAMEWIDTH_ABS: pWidthAbsState = propertie; break; - case CTF_FRAMEWIDTH_REL: pWidthRelState = propertie; break; - case CTF_FRAMEHEIGHT_ABS: pHeightAbsState = propertie; break; case CTF_FRAMEHEIGHT_MIN_ABS: pHeightMinAbsState = propertie; break; - case CTF_FRAMEHEIGHT_REL: pHeightRelState = propertie; break; case CTF_FRAMEHEIGHT_MIN_REL: pHeightMinRelState = propertie; break; + case CTF_FRAMEHEIGHT_ABS: pHeightAbsState = propertie; break; + case CTF_FRAMEHEIGHT_REL: pHeightRelState = propertie; break; case CTF_SIZETYPE: pSizeTypeState = propertie; break; - case CTF_SYNCHEIGHT: pSyncHeightState = propertie; break; case CTF_WRAP: pWrapState = propertie; break; case CTF_WRAP_CONTOUR: pWrapContourState = propertie; break; @@ -759,55 +751,30 @@ void XMLTextExportPropertySetMapper::ContextFilter( } } - if( pWidthAbsState && pWidthRelState ) + sal_Int16 nSizeType = SizeType::FIX; + if( pSizeTypeState ) { - sal_Int16 nRelWidth = 0; - pWidthRelState->maValue >>= nRelWidth; - if( nRelWidth > 0 ) - pWidthAbsState->mnIndex = -1; - // TODO: instead of checking this value for 255 a new property - // must be introduced like for heights. - if( nRelWidth == 255 ) - pWidthRelState->mnIndex = -1; + pSizeTypeState->maValue >>= nSizeType; + pSizeTypeState->mnIndex = -1; } - if( pHeightAbsState && pHeightRelState ) + if( pHeightMinAbsState ) { - DBG_ASSERT( pHeightMinAbsState, "no min abs state" ); - DBG_ASSERT( pHeightMinRelState, "no min rel state" ); - sal_Int32 nSizeType = SizeType::FIX; - if( pSizeTypeState ) - pSizeTypeState->maValue >>= nSizeType; - - if( SizeType::VARIABLE == nSizeType || - ( pSyncHeightState && - *(sal_Bool *)pSyncHeightState->maValue.getValue() ) ) + sal_Int8 nRel; + if( (SizeType::MIN != nSizeType) || + (pHeightMinRelState && (pHeightMinRelState->maValue >>= nRel) && + nRel > 0) ) { - pHeightAbsState->mnIndex = -1; pHeightMinAbsState->mnIndex = -1; - pHeightRelState->mnIndex = -1; - pHeightMinRelState->mnIndex = -1; - } - else - { - sal_Int16 nRelHeight = 0; - pHeightRelState->maValue >>= nRelHeight; - sal_Bool bRel = (nRelHeight > 0); - sal_Bool bMin = (SizeType::MIN == nSizeType); - if( bRel || bMin ) - pHeightAbsState->mnIndex = -1; - if( bRel || !bMin ) - pHeightMinAbsState->mnIndex = -1; - if( !bRel || bMin ) - pHeightRelState->mnIndex = -1; - if( !bRel || !bMin ) - pHeightMinRelState->mnIndex = -1; } } - if( pSizeTypeState ) - pSizeTypeState->mnIndex = -1; - if( pSyncHeightState ) - pSyncHeightState->mnIndex = -1; + if( pHeightMinRelState && SizeType::MIN != nSizeType) + pHeightMinRelState->mnIndex = -1; + if( pHeightAbsState && pHeightMinAbsState && + -1 != pHeightMinAbsState->mnIndex ) + pHeightAbsState->mnIndex = -1; + if( pHeightRelState && SizeType::FIX != nSizeType) + pHeightRelState->mnIndex = -1; if( pWrapState ) { diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index d886f87e9837..9f515064090c 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtimp.cxx,v $ * - * $Revision: 1.37 $ + * $Revision: 1.38 $ * - * last change: $Author: dvo $ $Date: 2001-01-10 20:51:01 $ + * last change: $Author: mib $ $Date: 2001-01-15 11:28:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -433,9 +433,10 @@ static __FAR_DATA SvXMLTokenMapEntry aTextFrameAttrTokenMap[] = { XML_NAMESPACE_SVG, sXML_x, XML_TOK_TEXT_FRAME_X }, { XML_NAMESPACE_SVG, sXML_y, XML_TOK_TEXT_FRAME_Y }, { XML_NAMESPACE_SVG, sXML_width, XML_TOK_TEXT_FRAME_WIDTH }, -// { XML_NAMESPACE_FO, sXML_min_width, XML_TOK_TEXT_FRAME_MIN_WIDTH }, + { XML_NAMESPACE_STYLE, sXML_rel_width, XML_TOK_TEXT_FRAME_REL_WIDTH }, { XML_NAMESPACE_SVG, sXML_height, XML_TOK_TEXT_FRAME_HEIGHT }, { XML_NAMESPACE_FO, sXML_min_height, XML_TOK_TEXT_FRAME_MIN_HEIGHT }, + { XML_NAMESPACE_STYLE, sXML_rel_height, XML_TOK_TEXT_FRAME_REL_HEIGHT }, { XML_NAMESPACE_DRAW, sXML_chain_next_name, XML_TOK_TEXT_FRAME_NEXT_CHAIN_NAME }, { XML_NAMESPACE_XLINK, sXML_href, XML_TOK_TEXT_FRAME_HREF }, { XML_NAMESPACE_DRAW, sXML_name, XML_TOK_TEXT_FRAME_FILTER_NAME }, diff --git a/xmloff/source/text/txtimppr.cxx b/xmloff/source/text/txtimppr.cxx index 8b5ac29eb22a..fffcd5dfa2dc 100644 --- a/xmloff/source/text/txtimppr.cxx +++ b/xmloff/source/text/txtimppr.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtimppr.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: mib $ $Date: 2000-11-13 08:42:14 $ + * last change: $Author: mib $ $Date: 2001-01-15 11:28:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,6 +72,9 @@ #ifndef _COM_SUN_STAR_TEXT_VERTORIENTATION_HPP_ #include <com/sun/star/text/VertOrientation.hpp> #endif +#ifndef _COM_SUN_STAR_TEXT_SIZETYPE_HPP_ +#include <com/sun/star/text/SizeType.hpp> +#endif #ifndef _XMLOFF_XMLFONTSTYLESCONTEXT_HXX_ #include "XMLFontStylesContext.hxx" #endif @@ -166,6 +169,7 @@ XMLTextImportPropertyMapper::XMLTextImportPropertyMapper( const UniReference< XMLPropertySetMapper >& rMapper, XMLFontStylesContext *pFontDecls ) : SvXMLImportPropertyMapper( rMapper ), + nSizeTypeIndex( -2 ), xFontDecls( pFontDecls ) { } @@ -211,6 +215,9 @@ void XMLTextImportPropertyMapper::finished( ::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const { + sal_Bool bHasAnyHeight = sal_False; + sal_Bool bHasAnyMinHeight = sal_False; + XMLPropertyState* pFontFamilyName = 0; XMLPropertyState* pFontStyleName = 0; XMLPropertyState* pFontFamily = 0; @@ -281,6 +288,17 @@ void XMLTextImportPropertyMapper::finished( case CTF_ANCHORTYPE: pAnchorType = property; break; case CTF_VERTICALPOS: pVertOrient = property; break; case CTF_VERTICALREL_ASCHAR: pVertOrientRelAsChar = property; break; + + case CTF_FRAMEHEIGHT_MIN_ABS: + case CTF_FRAMEHEIGHT_MIN_REL: +// case CTF_SYNCHEIGHT_MIN: + bHasAnyMinHeight = sal_True; + // no break here! + case CTF_FRAMEHEIGHT_ABS: + case CTF_FRAMEHEIGHT_REL: +// case CTF_SYNCHEIGHT: + bHasAnyHeight = sal_True; break; + } } @@ -468,6 +486,35 @@ void XMLTextImportPropertyMapper::finished( } pVertOrientRelAsChar->mnIndex = -1; } + + if( bHasAnyHeight ) + { + if( nSizeTypeIndex == -2 ) + { + const_cast < XMLTextImportPropertyMapper * > ( this ) + ->nSizeTypeIndex = -1; + sal_Int32 nCount = getPropertySetMapper()->GetEntryCount(); + for( sal_Int32 i=0; i < nCount; i++ ) + { + if( CTF_SIZETYPE == getPropertySetMapper() + ->GetEntryContextId( i ) ) + { + const_cast < XMLTextImportPropertyMapper * > ( this ) + ->nSizeTypeIndex = i; + break; + } + } + } + if( nSizeTypeIndex != -1 ) + { + XMLPropertyState aSizeTypeState( nSizeTypeIndex ); + aSizeTypeState.maValue <<= (sal_Int16)( bHasAnyMinHeight + ? SizeType::MIN + : SizeType::FIX); + rProperties.push_back( aSizeTypeState ); + } + } + } diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 1d1c53a76dad..d1365cf0c70a 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtparae.cxx,v $ * - * $Revision: 1.43 $ + * $Revision: 1.44 $ * - * last change: $Author: mib $ $Date: 2001-01-03 11:32:11 $ + * last change: $Author: mib $ $Date: 2001-01-15 11:28:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -674,7 +674,8 @@ XMLTextParagraphExport::XMLTextParagraphExport( sHeight(RTL_CONSTASCII_USTRINGPARAM("Height")), sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight")), sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType")), - sSizeRelative(RTL_CONSTASCII_USTRINGPARAM("SizeRelative")), + sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight")), + sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth")), sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")), sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")), sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient")), @@ -943,7 +944,7 @@ void XMLTextParagraphExport::exportPageFrames( sal_Bool bAutoStyles, { if( pPageTextFrameIdxs ) { - for( sal_Int32 i = 0; i < pPageTextFrameIdxs->Count(); i++ ) + for( sal_uInt16 i = 0; i < pPageTextFrameIdxs->Count(); i++ ) { Any aAny = xTextFrames->getByIndex( (*pPageTextFrameIdxs)[i] ); Reference < XTextFrame > xTxtFrame; @@ -954,7 +955,7 @@ void XMLTextParagraphExport::exportPageFrames( sal_Bool bAutoStyles, } if( pPageGraphicIdxs ) { - for( sal_Int32 i = 0; i < pPageGraphicIdxs->Count(); i++ ) + for( sal_uInt16 i = 0; i < pPageGraphicIdxs->Count(); i++ ) { Any aAny = xGraphics->getByIndex( (*pPageGraphicIdxs)[i] ); Reference < XTextContent > xTxtCntnt; @@ -964,7 +965,7 @@ void XMLTextParagraphExport::exportPageFrames( sal_Bool bAutoStyles, } if( pPageEmbeddedIdxs ) { - for( sal_Int32 i = 0; i < pPageEmbeddedIdxs->Count(); i++ ) + for( sal_uInt16 i = 0; i < pPageEmbeddedIdxs->Count(); i++ ) { Any aAny = xEmbeddeds->getByIndex( (*pPageEmbeddedIdxs)[i] ); Reference < XTextContent > xTxtCntnt; @@ -974,7 +975,7 @@ void XMLTextParagraphExport::exportPageFrames( sal_Bool bAutoStyles, } if( pPageShapeIdxs ) { - for( sal_Int32 i = 0; i < pPageShapeIdxs->Count(); i++ ) + for( sal_uInt16 i = 0; i < pPageShapeIdxs->Count(); i++ ) { Any aAny = xShapes->getByIndex( (*pPageShapeIdxs)[i] ); Reference < XShape > xShape; @@ -1489,83 +1490,89 @@ sal_Int32 XMLTextParagraphExport::addTextFrameAttributes( Reference< XPropertySetInfo > xPropSetInfo = rPropSet->getPropertySetInfo(); // svg:width - sal_Int8 nRelWidth = 0; - if( xPropSetInfo->hasPropertyByName( sRelativeWidth ) ) + if( xPropSetInfo->hasPropertyByName( sWidth ) ) { + sal_Int32 nWidth = 0; + aAny = rPropSet->getPropertyValue( sWidth ); + aAny >>= nWidth; + GetExport().GetMM100UnitConverter().convertMeasure( sValue, nWidth ); + GetExport().AddAttribute( XML_NAMESPACE_SVG, sXML_width, + sValue.makeStringAndClear() ); + } + sal_Bool bSyncWidth = sal_False; + if( xPropSetInfo->hasPropertyByName( sIsSyncWidthToHeight ) ) + { + aAny = rPropSet->getPropertyValue( sIsSyncWidthToHeight ); + bSyncWidth = *(sal_Bool *)aAny.getValue(); + if( bSyncWidth ) + GetExport().AddAttributeASCII( XML_NAMESPACE_STYLE, sXML_rel_width, + sXML_scale ); + } + if( !bSyncWidth && xPropSetInfo->hasPropertyByName( sRelativeWidth ) ) + { + sal_Int8 nRelWidth = 0; aAny = rPropSet->getPropertyValue( sRelativeWidth ); aAny >>= nRelWidth; DBG_ASSERT( nRelWidth >= 0 && nRelWidth <= 100, "Got illegal relative width from API" ); - } - if( nRelWidth > 0 ) - { - // TODO: instead of checking this value for 255 a new property - // must be introduced like for heights. - if( nRelWidth != 255 ) + if( nRelWidth > 0 ) + { GetExport().GetMM100UnitConverter().convertPercent( sValue, nRelWidth ); + GetExport().AddAttribute( XML_NAMESPACE_STYLE, sXML_rel_width, + sValue.makeStringAndClear() ); + } } - else if( xPropSetInfo->hasPropertyByName( sWidth ) ) + // svg:height, fo:min-height or style:rel-height + sal_Int16 nSizeType = SizeType::FIX; + if( xPropSetInfo->hasPropertyByName( sSizeType ) ) { - sal_Int32 nWidth = 0; - aAny = rPropSet->getPropertyValue( sWidth ); - aAny >>= nWidth; - GetExport().GetMM100UnitConverter().convertMeasure( sValue, nWidth ); + aAny = rPropSet->getPropertyValue( sSizeType ); + aAny >>= nSizeType; } - if( sValue.getLength() ) - GetExport().AddAttribute( XML_NAMESPACE_SVG, sXML_width, - sValue.makeStringAndClear() ); - - // svg:height or fo:min-height sal_Bool bSyncHeight = sal_False; - if( xPropSetInfo->hasPropertyByName( sSizeRelative ) ) + if( xPropSetInfo->hasPropertyByName( sIsSyncHeightToWidth ) ) { - aAny = rPropSet->getPropertyValue( sSizeRelative ); + aAny = rPropSet->getPropertyValue( sIsSyncHeightToWidth ); bSyncHeight = *(sal_Bool *)aAny.getValue(); } - - sal_Int16 nSizeType = SizeType::FIX; - if( xPropSetInfo->hasPropertyByName( sSizeType ) ) + sal_Int8 nRelHeight = 0; + if( !bSyncHeight && xPropSetInfo->hasPropertyByName( sRelativeHeight ) ) { - aAny = rPropSet->getPropertyValue( sSizeType ); - aAny >>= nSizeType; + aAny = rPropSet->getPropertyValue( sRelativeHeight ); + aAny >>= nRelHeight; } - - DBG_ASSERT( !bSyncHeight || SizeType::VARIABLE != nSizeType, - "sync height and variable size unexpected" ); - - if( !bSyncHeight && SizeType::VARIABLE != nSizeType ) + if( xPropSetInfo->hasPropertyByName( sHeight ) ) { - sal_Int8 nRelHeight = 0; - if( xPropSetInfo->hasPropertyByName( sRelativeHeight ) ) - { - aAny = rPropSet->getPropertyValue( sRelativeHeight ); - aAny >>= nRelHeight; - } - if( nRelHeight > 0 ) - { - GetExport().GetMM100UnitConverter().convertPercent( sValue, - nRelHeight ); - } - else if( xPropSetInfo->hasPropertyByName( sHeight ) ) + sal_Int32 nHeight = 0; + aAny = rPropSet->getPropertyValue( sHeight ); + aAny >>= nHeight; + GetExport().GetMM100UnitConverter().convertMeasure( sValue, + nHeight ); + if( SizeType::MIN == nSizeType && 0==nRelHeight && !bSyncHeight ) + GetExport().AddAttribute( XML_NAMESPACE_FO, sXML_min_height, + sValue.makeStringAndClear() ); + else + GetExport().AddAttribute( XML_NAMESPACE_SVG, sXML_height, + sValue.makeStringAndClear() ); + } + if( bSyncHeight ) + { + GetExport().AddAttributeASCII( XML_NAMESPACE_STYLE, sXML_rel_height, + SizeType::MIN == nSizeType ? sXML_scale_min : sXML_scale ); - { - sal_Int32 nHeight = 0; - aAny = rPropSet->getPropertyValue( sHeight ); - aAny >>= nHeight; - GetExport().GetMM100UnitConverter().convertMeasure( sValue, - nHeight ); - } - if( sValue.getLength() ) - { - if( SizeType::MIN == nSizeType ) - GetExport().AddAttribute( XML_NAMESPACE_FO, sXML_min_height, - sValue.makeStringAndClear() ); - else - GetExport().AddAttribute( XML_NAMESPACE_SVG, sXML_height, - sValue.makeStringAndClear() ); - } + } + else if( nRelHeight > 0 ) + { + GetExport().GetMM100UnitConverter().convertPercent( sValue, + nRelHeight ); + if( SizeType::MIN == nSizeType ) + GetExport().AddAttribute( XML_NAMESPACE_FO, sXML_min_height, + sValue.makeStringAndClear() ); + else + GetExport().AddAttribute( XML_NAMESPACE_STYLE, sXML_rel_height, + sValue.makeStringAndClear() ); } OUString sZOrder( RTL_CONSTASCII_USTRINGPARAM( "ZOrder" ) ); diff --git a/xmloff/source/text/txtprhdl.cxx b/xmloff/source/text/txtprhdl.cxx index 10b32b1a2374..9bd3ba2d5b6b 100644 --- a/xmloff/source/text/txtprhdl.cxx +++ b/xmloff/source/text/txtprhdl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtprhdl.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: sab $ $Date: 2000-12-01 17:18:16 $ + * last change: $Author: mib $ $Date: 2001-01-15 11:28:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1051,6 +1051,113 @@ sal_Bool XMLTextCombineCharPropHdl_Impl::exportXML( XMLTextCombineCharPropHdl_Impl::~XMLTextCombineCharPropHdl_Impl() { } + +// --------------------------------------------------------------------------- + +class XMLTextRelWidthHeightPropHdl_Impl : public XMLPropertyHandler +{ +public: + XMLTextRelWidthHeightPropHdl_Impl() {} + virtual ~XMLTextRelWidthHeightPropHdl_Impl(); + + virtual sal_Bool importXML( + const ::rtl::OUString& rStrImpValue, + ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const; + virtual sal_Bool exportXML( + ::rtl::OUString& rStrExpValue, + const ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const; +}; + +sal_Bool XMLTextRelWidthHeightPropHdl_Impl::importXML( + const OUString& rStrImpValue, + Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRet; + sal_Int32 nValue; + bRet = rUnitConverter.convertPercent( nValue, rStrImpValue ); + if( bRet ) + rValue <<= (sal_Int8)nValue; + + return bRet; +} + +sal_Bool XMLTextRelWidthHeightPropHdl_Impl::exportXML( + OUString& rStrExpValue, + const Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRet = sal_False; + sal_Int8 nValue; + rValue >>= nValue; + if( nValue > 0 ) + { + OUStringBuffer aOut; + rUnitConverter.convertPercent( aOut, nValue ); + rStrExpValue = aOut.makeStringAndClear(); + + bRet = sal_True; + } + + return bRet; +} + +XMLTextRelWidthHeightPropHdl_Impl::~XMLTextRelWidthHeightPropHdl_Impl() +{ +} + +// --------------------------------------------------------------------------- + +class XMLTextSyncWidthHeightPropHdl_Impl : public XMLPropertyHandler +{ + const OUString sValue; + +public: + XMLTextSyncWidthHeightPropHdl_Impl( const sal_Char *pValue ) : + sValue( OUString::createFromAscii(pValue) ) {} + virtual ~XMLTextSyncWidthHeightPropHdl_Impl(); + + virtual sal_Bool importXML( + const ::rtl::OUString& rStrImpValue, + ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const; + virtual sal_Bool exportXML( + ::rtl::OUString& rStrExpValue, + const ::com::sun::star::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const; +}; + +sal_Bool XMLTextSyncWidthHeightPropHdl_Impl::importXML( + const OUString& rStrImpValue, + Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bValue = (rStrImpValue == sValue ); + rValue.setValue( &bValue, ::getBooleanCppuType() ); + + return sal_True; +} + +sal_Bool XMLTextSyncWidthHeightPropHdl_Impl::exportXML( + OUString& rStrExpValue, + const Any& rValue, + const SvXMLUnitConverter& rUnitConverter ) const +{ + sal_Bool bRet = sal_False; + if( *(sal_Bool *)rValue.getValue() ) + { + rStrExpValue = sValue; + bRet = sal_True; + } + + return bRet; +} + +XMLTextSyncWidthHeightPropHdl_Impl::~XMLTextSyncWidthHeightPropHdl_Impl() +{ +} // --------------------------------------------------------------------------- class XMLTextPropertyHandlerFactory_Impl { @@ -1165,6 +1272,15 @@ const XMLPropertyHandler *XMLTextPropertyHandlerFactory_Impl::GetPropertyHandler OUString( RTL_CONSTASCII_USTRINGPARAM( sXML_strict ) ), OUString( RTL_CONSTASCII_USTRINGPARAM( sXML_normal ) ) ); break; + case XML_TYPE_TEXT_REL_WIDTH_HEIGHT: + pHdl = new XMLTextRelWidthHeightPropHdl_Impl; + break; + case XML_TYPE_TEXT_SYNC_WIDTH_HEIGHT: + pHdl = new XMLTextSyncWidthHeightPropHdl_Impl( sXML_scale ); + break; + case XML_TYPE_TEXT_SYNC_WIDTH_HEIGHT_MIN: + pHdl = new XMLTextSyncWidthHeightPropHdl_Impl( sXML_scale_min ); + break; } return pHdl; diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx index 0e72e09a0bc5..606fb7e2bc28 100644 --- a/xmloff/source/text/txtprmap.cxx +++ b/xmloff/source/text/txtprmap.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtprmap.cxx,v $ * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * - * last change: $Author: mib $ $Date: 2001-01-05 10:02:58 $ + * last change: $Author: mib $ $Date: 2001-01-15 11:28:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -473,14 +473,19 @@ XMLPropertyMapEntry aXMLFramePropMap[] = // RES_FILL_ORDER // TODO: not required??? // RES_FRM_SIZE - M_ED( "Width", SVG, width, XML_TYPE_MEASURE|MID_FLAG_MULTI_PROPERTY, CTF_FRAMEWIDTH_ABS ), - M_ED( "RelativeWidth", SVG, width, XML_TYPE_PERCENT8, CTF_FRAMEWIDTH_REL ), - M_ED( "Height", SVG, height, XML_TYPE_MEASURE|MID_FLAG_MULTI_PROPERTY, CTF_FRAMEHEIGHT_ABS ), + M_ED( "Width", SVG, width, XML_TYPE_MEASURE, 0 ), + M_ED( "RelativeWidth", STYLE, rel_width, XML_TYPE_TEXT_REL_WIDTH_HEIGHT, 0 ), +// M_ED( "RelativeWidth", STYLE, rel_width, XML_TYPE_TEXT_REL_WIDTH_HEIGHT|MID_FLAG_MULTI_PROPERTY, 0 ), +// M_ED( "IsSyncWidthToHeight",STYLE, rel_width, XML_TYPE_TEXT_SYNC_WIDTH_HEIGHT|MID_FLAG_MULTI_PROPERTY, 0 ), + + M_ED( "Height", SVG, height, XML_TYPE_MEASURE, CTF_FRAMEHEIGHT_ABS ), M_ED( "Height", FO, min_height, XML_TYPE_MEASURE|MID_FLAG_MULTI_PROPERTY, CTF_FRAMEHEIGHT_MIN_ABS ), - M_ED( "RelativeHeight", SVG, height, XML_TYPE_PERCENT8, CTF_FRAMEHEIGHT_REL ), - M_ED( "RelativeHeight", FO, min_height, XML_TYPE_PERCENT8, CTF_FRAMEHEIGHT_MIN_REL ), + M_ED( "RelativeHeight", FO, min_height, XML_TYPE_TEXT_REL_WIDTH_HEIGHT, CTF_FRAMEHEIGHT_MIN_REL ), + M_ED( "RelativeHeight", STYLE, rel_height, XML_TYPE_TEXT_REL_WIDTH_HEIGHT, CTF_FRAMEHEIGHT_REL ), +// M_ED( "RelativeHeight", STYLE, rel_height, XML_TYPE_TEXT_REL_WIDTH_HEIGHT|MID_FLAG_MULTI_PROPERTY, CTF_FRAMEHEIGHT_REL ), +// M_ED( "IsSyncHeightToWidth",STYLE, rel_height, XML_TYPE_TEXT_SYNC_WIDTH_HEIGHT|MID_FLAG_MULTI_PROPERTY, CTF_SYNCHEIGHT ), +// M_ED( "IsSyncHeightToWidth",STYLE, rel_height, XML_TYPE_TEXT_SYNC_WIDTH_HEIGHT_MIN, CTF_SYNCHEIGHT_MIN ), M_ED( "SizeType", FO, text_box, XML_TYPE_NUMBER16|MID_FLAG_SPECIAL_ITEM_IMPORT, CTF_SIZETYPE ), - M_ED( "SizeRelative", FO, text_box, XML_TYPE_BOOL|MID_FLAG_SPECIAL_ITEM_IMPORT, CTF_SYNCHEIGHT ), // RES_PAPER_BIN // not required // RES_ANCHOR @@ -676,7 +681,7 @@ XMLPropertyMapEntry *lcl_txtprmap_getMap( sal_uInt16 nType ) pMap = aXMLFramePropMap; break; case TEXT_PROP_MAP_AUTO_FRAME: - pMap = &(aXMLFramePropMap[12]); + pMap = &(aXMLFramePropMap[11]); DBG_ASSERT( pMap->msXMLName == sXML_margin_left, "frame map changed" ); break; case TEXT_PROP_MAP_SHAPE: |